
/**
 * Created by xiongshilin on 2017/3/22.
 */
(function(domain){
    if(domain.AGEF){
        domain.AGEF = {};
    }
    function createNamespace() {
        var a = arguments,o = null,d,rt;
        for(var i = 0,l1 = a.length; i < l1; i++){
            d = a[i].split('.');
            rt = d[0];
            eval('if (typeof ' + rt + ' == "undefined"){' + rt + ' = {};} o = ' + rt + ';');
            for(var j = 1,l2 = d.length; j < l2; j++){
                o[d[j]] = o[d[j]] || {};
                o = o[d[j]];
            }
        }
    }
    createNamespace('AGEF');

})(window);
/**
 * Created by xiongshilin on 2017/3/24.
 */
(function(){
    AGEF.AbrazosGraphicalViewerImpl = function(container) {
        this.abrazosRootElement = null;
        this.widgetFactory = null;
        this.container = container;
        this.selectionDispatcher = null;
        AGEF.AbrazosGraphicalViewerImpl.superclass.constructor.call(this);
    };
    AGEF.AbrazosGraphicalViewerImpl.SELECTION_GRAPHICAL = "selectionGraphical";
    var superClass = COM.gef.GraphicalViewerImpl;
    COM.util.defineClass(AGEF.AbrazosGraphicalViewerImpl, superClass,{
        createControl: function() {
            var abrazosRootElement = document.createElement("div");
            abrazosRootElement.style.position="relative";
            abrazosRootElement.style.top="0px";
            abrazosRootElement.style.left="0px";
            abrazosRootElement.style.zIndex="0";
            abrazosRootElement.id = 'abrazos-control';
            this.getElement().appendChild(abrazosRootElement);
            this.setAbrazosRootElement(abrazosRootElement);
            AGEF.AbrazosGraphicalViewerImpl.superclass.createControl.call(this);
            this.getElement().lastElementChild.style.zIndex="1";
        },
        createDefaultRoot: function () {
            var rootEditPart = new AGEF.AbrazosFreeformRootEditPart();
            this.setRootEditPart(rootEditPart);
        },
        setRootEditPart: function(rootEditPart) {
            AGEF.AbrazosGraphicalViewerImpl.superclass.setRootEditPart.call(this, rootEditPart);
            var figure = rootEditPart.getFigure();
            var rootControl = figure.getWidget();
            if(rootControl) {
                this.getAbrazosRootElement().appendChild(rootControl.getDomElement());
            }
        },
        setSize: function(width,height) {
            AGEF.AbrazosGraphicalViewerImpl.superclass.setSize.call(this, width,height);
            var element = this.getAbrazosRootElement();
            element.style.width = width + 'px';
            element.style.height = height + 'px';
        },
        setWidgetFactory: function(widgetFactory) {
            this.widgetFactory = widgetFactory;
        },
        getWidgetFactory: function() {
            if(this.widgetFactory == null) {
                this.widgetFactory = new AGEF.DefaultControlFactory();
            }
            return this.widgetFactory;
        },
        setAbrazosRootElement: function(element) {
            this.abrazosRootElement = element;
        },
        getAbrazosRootElement: function(){
            return this.abrazosRootElement;
        },
        addSelectionDispatcher: function(dispatcher) {
            this.selectionDispatcher = dispatcher;
            this.addSelectionChangedListener({
                selectionChanged: function(obj, selection) {
                    this.selectionDispatcher.notifyChange(AGEF.AbrazosGraphicalViewerImpl.SELECTION_GRAPHICAL, {source:obj, selection:selection});
                }.bind(this)
            });
            this.selectionDispatcher.addListener(AGEF.PaletteViewer.SELECTION_TOOL, { update: function(arg) {
                if(arg.activatedTool){
                    this.getEditDomain().setActiveTool(arg.activatedTool);
                }
            }.bind(this)});
            this.selectionDispatcher.addListener(AGEF.OutlineViewer.OUTLINE_CHANGE, {update: function(arg) {
                // if(arg.type == "selection"){
                //     for(var index in arg.data) {
                //         var editPart = this.getEditPartRegistry().get(arg.data[index]);
                //         this.select(editPart);
                //     }
                // }
            }.bind(this)});
        }
    });
})();
/**
 * Created by xiongshilin on 2017/3/28.
 */
(function(){
    AGEF.ControlFactory = function() {};
    AGEF.ControlFactory.prototype.createControl = Function.needOverride;
})();
/**
 * Created by xiongshilin on 2017/3/28.
 */
(function(){
    AGEF.DefaultControlFactory = function() {
        AGEF.DefaultControlFactory.superclass.constructor.call(this);
        this.controlClassRegistry = new COM.draw2d.Map();
    };
    var superClass = AGEF.ControlFactory;
    COM.util.defineClass(AGEF.DefaultControlFactory, superClass, {
        createControl: function(model){
            var controlClass = this.controlClassRegistry.get(model.constructor);
            if(controlClass) {
                var control = new controlClass();
                control.createDomElement(model);
                return control;
            } else {
                throw new Error(model + " associated control is undefined");
            }
        },
        registryControlClass: function(modelClass, controlClass){
            if(modelClass == null || controlClass == null) {
               return;
            } else {
                this.controlClassRegistry.put(modelClass, controlClass);
            }
        },
        removeControlClass: function(modelClass) {
            this.controlClassRegistry.remove(modelClass);
        }
    });
})();
/**
 * Created by xiongshilin on 2017/3/30.
 */
(function(){
    AGEF.AbrazosEditDomain = function(shell) {
        AGEF.AbrazosEditDomain.superclass.constructor.call(this, shell);
    };
    var superClass = COM.gef.EditDomain;
    COM.util.defineClass(AGEF.AbrazosEditDomain, superClass, {
    });
})();
/**
 * Created by xiongshilin on 2017/4/6.
 */
(function(){
    AGEF.AbrazosCreationTool = function(factory) {
        AGEF.AbrazosCreationTool.superclass.constructor.call(this, factory);
    };
    AGEF.AbrazosCreationTool.LABEL = "abrazos-creation-tool";
    var superClass = COM.gef.CreationTool;
    COM.util.defineClass(AGEF.AbrazosCreationTool, superClass, {
        setBeingCreatedModel: function(model) {
            if(!model) {
                return;
            }
            var factory = {};
            factory.getNewObject = function(){
                return model;
            };
            factory.getObjectType = function(){
                return model.getType();
            };
            this.setFactory(factory);
        },
        eraseTargetFeedback: function () {
            if (!this.isShowingTargetFeedback()) {
                return;
            }
            if (this.getTargetEditPart() != null){
                this.getTargetEditPart().eraseTargetFeedback(this.getTargetRequest());
            }
            this.setFlag(COM.gef.TargetingTool.FLAG_TARGET_FEEDBACK, false);
        }
    });
})();
/**
 * Created by xiongshilin on 2017/4/6.
 */
(function(){
    AGEF.AbrazosSelectionTool = function() {
        AGEF.AbrazosSelectionTool.superclass.constructor.call(this);
    };
    AGEF.AbrazosSelectionTool.LABEL = "abrazos-selection-tool";
    var superClass = COM.gef.SelectionTool;
    COM.util.defineClass(AGEF.AbrazosSelectionTool, superClass, {

    });
})();/**
 * Created by jiangqifan on 2017/6/12.
 */
(function(){
    AGEF.AbrazosMarqueeSelectionTool = function() {
        AGEF.AbrazosMarqueeSelectionTool.superclass.constructor.call(this);
    };
    AGEF.AbrazosMarqueeSelectionTool.LABEL = "abrazos-marquee-selection-tool";
    var superClass = COM.gef.MarqueeSelectionTool;
    COM.util.defineClass(AGEF.AbrazosMarqueeSelectionTool, superClass, {

    });
})();

/**
 * Created by xiongshilin on 2017/4/6.
 */
(function() {
    AGEF.ChangeValueRequest = function() {
        AGEF.ChangeValueRequest.superclass.constructor.call(this);
        this.value = null;
        this.propertyName = null;
        this.setType(AGEF.ChangeValueRequest.TYPE);
    };
    AGEF.ChangeValueRequest.TYPE = "change_value";
    var superClass = COM.gef.Request;
    COM.util.defineClass(AGEF.ChangeValueRequest, superClass, {
        setPropertyName: function(propName) {
            this.propertyName = propName;
        },
        getPropertyName: function() {
            return this.propertyName;
        },
        setValue: function(value) {
            this.value = value;
        },
        getValue: function() {
            return this.value;
        }
    });
})();
/**
 * Created by xiongshilin on 2017/3/24.
 */
(function(){
    AGEF.Action = function() {
        this.ID = null;
        this.enable = false;
    };
    var superClass = Object;
    COM.util.defineClass(AGEF.Action, superClass, {
        setActionID: function(id) {
            this.ID = id;
        },
        getActionID: function() {
            return this.ID;
        },
        calculateEnable: function() {

            return this.enable;
        },
        run: Function.needOverride
    });
})();
/**
 * Created by xiongshilin on 2017/3/24.
 */
(function(){
    AGEF.WidgetFigure = function(id) {
        AGEF.WidgetFigure.superclass.constructor.call(this, id);
        this.id = id;
        this.widget = null;
    };
    var superClass = COM.draw2d.RectangleFigure;
    COM.util.defineClass(AGEF.WidgetFigure, superClass, {
        setWidget: function(widget) {
            this.widget = widget;
        },
        getWidget: function() {
            return this.widget;
        },
        paintFill: function(graphics){
            var bounds = this.getBounds();
            graphics.fillText(this.id, bounds.x+6, bounds.y+10);
        },
        outlineShape: function(graphics){
        },
        setLayoutData : function(data){
            this.getWidget().setLayoutData(data);
            this.revalidate();
        },

        getLayoutData : function(data){
            return this.getWidget().getLayoutData();
        },

        getPreferredSize: function() {
            var widgetBounds = this.getWidget().getBounds();
            var size = new COM.draw2d.Dimension(widgetBounds.width, widgetBounds.height);
            this.prefSize = size;
            return this.prefSize;
        }
    });
})();
/**
 * Created by xiongshilin on 2017/3/30.
 */
(function() {
    AGEF.CompositeFigure = function(id) {
        AGEF.CompositeFigure.superclass.constructor.call(this, id);
    };
    var superClass = AGEF.WidgetFigure;
    COM.util.defineClass(AGEF.CompositeFigure, superClass, {
        getChildConstraint: function(child, constraint) {
            var copy = constraint ? constraint.copy() : new COM.draw2d.Rectangle();
            var widgetBounds = child.getWidget().getBounds();
            copy.setLocation(widgetBounds.x, widgetBounds.y);
            copy.setSize(widgetBounds.width, widgetBounds.height);
            return copy;
        },

        addChildWidget:function(child, constraint, index){
            this.widget.addChild(child.getWidget());
            return this.getChildConstraint(child, constraint);
        },
        add: function(child, constraint, index){
            var newConstraint = this.addChildWidget(child, constraint, index);
            if(newConstraint) {
                //constraint = newConstraint;
                child.setBounds(newConstraint);
            }
            AGEF.CompositeFigure.superclass.add.call(this, child, constraint, index);
        },
        remove: function(child) {
            AGEF.CompositeFigure.superclass.remove.call(this, child);
            this.widget.removeChild(child.getWidget());
        },
        layout : function(){
            if(this.layoutManager){
                var children = this.getChildren(), that = this;
                children.forEach(function(child, index, array){
                    if(child.getWidget().needLayout()){
                        child.revalidate();
                    }
                    that.getWidget().layoutChild(child.getWidget());
                    child.getWidget().setLayouted(true);
                    var widgetBounds = child.getWidget().getBounds();
                    var newConstraint = new COM.draw2d.Rectangle(widgetBounds.x, widgetBounds.y, widgetBounds.width, widgetBounds.height);
                    that.getLayoutManager().setConstraint(child, newConstraint);
                });
                this.layoutManager.layout(this);
            }
        }
    });
})();
/**
 * Created by xiongshilin on 2017/3/30.
 */
(function() {
    AGEF.AbrazosFreeformLayer = function(id) {
        AGEF.AbrazosFreeformLayer.superclass.constructor.call(this, id);
    };
    var superClass = COM.draw2d.FreeformLayer;
    COM.util.defineClass(AGEF.AbrazosFreeformLayer, superClass, {
        add: function(child, constraint, index){
            this.addChildWidget(child, constraint, index);
            AGEF.AbrazosFreeformLayer.superclass.add.call(this, child, constraint, index);
        },
        addChildWidget: function(child, constraint, index) {
            var viewPort = this.getParent().getParent().getParent();
            if(viewPort.getWidget) {
                var childWidget = child.getWidget();
                viewPort.getWidget().addChild(child.getWidget());
            }
        },
        remove: function(child) {
            this.widget.removeChild(child.getWidget());
            AGEF.AbrazosFreeformLayer.superclass.remove.call(this, child);
        }
    });
})();
/**
 * Created by xiongshilin on 2017/3/27.
 */
(function(){
    AGEF.WidgetFreeformViewport = function(id) {
        AGEF.WidgetFreeformViewport.superclass.constructor.call(this, id);
        this.widget = null;
    };
    var superClass = COM.draw2d.FreeformViewport;
    COM.util.defineClass(AGEF.WidgetFreeformViewport, superClass, {
        add: function(child, constraint, index){
            this.addChildWidget(child, constraint, index);
            AGEF.WidgetFreeformViewport.superclass.add.call(this, child, constraint, index);
        },
        addChildWidget: function(child, constraint, index) {
            if(child.getWidget) {
                this.getWidget().addChild(child.getWidget());
            }
        },
        getChildConstraint: function() {
            //something to do
        },
        remove: function(child) {
            this.widget.removeChild(child.getWidget());
            AGEF.WidgetFreeformViewport.superclass.remove.call(this, child);
        },
        getWidget:function() {
            if(!this.widget) {
                this.widget = new AGEF.RootControl();
            }
            return this.widget;
        },
        setWidget: function(widget) {
            this.widget = widget;
        }
    });
})();
/**
 * Created by xiongshilin on 2017/3/29.
 */
(function(){
    AGEF.AbrazosUnlimitedFreeformFigure = function(id) {
        AGEF.AbrazosUnlimitedFreeformFigure.superclass.constructor.call(this, id);
        this.widget = null;
    };

    var superClass = COM.gef.UnlimitedFreeformFigure;

    COM.util.defineClass(AGEF.AbrazosUnlimitedFreeformFigure, superClass, {
        paintFigure: function(graphics){
            AGEF.AbrazosUnlimitedFreeformFigure.superclass.constructor.superclass.paintFigure.call(this,graphics);
            var bounds = this.getBounds();
            graphics.saveState();
            graphics.setFillStyle('rgba(255, 255, 255, 0)');
            graphics.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
            graphics.restoreState();
            if(this._background != null){
                COM.gef.ImageHelper.draw(this._background,this._backgroundPadding,graphics,bounds.x,bounds.y,bounds.width,bounds.height);
            }
        },
        add: function(child, constraint, index){
            var newConstraint = this.addChildWidget(child, constraint, index);
            if(newConstraint) {
                //constraint = newConstraint;
                child.setBounds(newConstraint);
            }
            AGEF.AbrazosUnlimitedFreeformFigure.superclass.add.call(this, child, constraint, index);
        },
        addChildWidget:function(child, constraint, index){
            this.widget.addChild(child.getWidget());
            return this.getChildConstraint(child, constraint);
        },
        getChildConstraint: function(child, constraint) {
            var copy = constraint ? constraint.copy() : new COM.draw2d.Rectangle();
            var widgetBounds = child.getWidget().getBounds();
            copy.setLocation(widgetBounds.x, widgetBounds.y);
            copy.setSize(widgetBounds.width, widgetBounds.height);
            return copy;
        },
        remove: function(child) {
            this.widget.removeChild(child.getWidget());
            AGEF.AbrazosUnlimitedFreeformFigure.superclass.remove.call(this, child);
        },
        getWidget:function() {
            if(!this.widget) {
                this.widget = new AGEF.ContentsControl();
            }
            return this.widget;
        },
        setWidget: function(widget) {
            this.widget = widget;
        }
    });
})();/**
 * Created by xiongshilin on 2017/3/24.
 */
(function(){

    if(!AGEF.functions){
      AGEF.functions = {};
    }

    if(AGEF.functions.editPartRefreshChildren){
      return;
    }

    //因为最后一个元素不会被重新add进去，所以dom元素无法置顶，所以重写了这个方法，保证所有元素都会按照新的顺序重新add一遍
    AGEF.functions.editPartRefreshChildren = function() {
        var i;
        var editPart;
        var model;
        var children = this.getChildren();
        var size = children.length;
        var trash;
        var ep;

        var modelToEditPart = new COM.draw2d.Map();

        if (size > 0) {
            for (i = 0; i < size; i++) {
                editPart = children[i];
                modelToEditPart.put(editPart.getModel(), editPart);
            }
        }

        var modelObjects = this.getModelChildren();
        for (i = 0; i < modelObjects.length; i++) {
            model = modelObjects[i];
            //model与editPart位置相同
            // if (i < children.length && children[i].getModel() === model) {
            //     continue;
            // }
            editPart = modelToEditPart.get(model);

            if (editPart != null) {
                //位置不同，调整位置
                this.reorderChild(editPart, i);
            } else {
                //没有editPart,创建并加入
                editPart = this.createChild(model);
                this.addChild(editPart, i);
            }
        }

        //移出多余的editPart
        size = children.length;
        if (i < size) {
            trash = [];
            for (; i < size; i++) {
                trash.push(children[i]);
            }
            for (i = 0; i < trash.length; i++) {
                ep = trash[i];
                this.removeChild(ep);
            }
        }
    }

})();

/**
 * Created by xiongshilin on 2017/3/24.
 */
(function(){
    AGEF.WidgetGraphicalEditPart = function() {
        AGEF.WidgetGraphicalEditPart.superclass.constructor.call(this);
    };
    var superClass = COM.gef.AbstractGraphicalEditPart;
    COM.util.defineClass(AGEF.WidgetGraphicalEditPart, superClass, {
        activate: function(){
            AGEF.WidgetGraphicalEditPart.superclass.activate.call(this);
            this.getModel().addPropertyChangeListener(this);
        },
        deactivate: function(){
            AGEF.WidgetGraphicalEditPart.superclass.deactivate.call(this);
            this.getModel().removePropertyChangeListener(this);
        },
        getWidgetFactory: function() {
            return this.getViewer().getWidgetFactory();
        },
        createFigure: function(){
            var figure = this._createFigure();
            figure.setLayoutData(this.getModel().getLayoutData());
            return figure;
        },
        _createFigure : Function.needOverride,
        propertyChange: function (evt) {
            if (AGEF.PropertyChangeEvent.UPDATE_EVENT == evt.getType()) {
                if (AGEF.BaseModel.PROPERTY_LAYOUTDATA == evt.getPropertyName()) {
                    this.getFigure().setLayoutData(evt.newValue);
                }
            }
        }
    });
})();
/**
 * Created by xiongshilin on 2017/3/27.
 */
(function(){
    AGEF.AbrazosFreeformRootEditPart = function() {
        AGEF.AbrazosFreeformRootEditPart.superclass.constructor.call(this);
    };
    var superClass = COM.gef.FreeformGraphicalRootEditPart;
    COM.util.defineClass(AGEF.AbrazosFreeformRootEditPart, superClass, {
        createFigure: function () {
            var viewport = new AGEF.WidgetFreeformViewport();
            this.innerLayers = new COM.draw2d.FreeformLayeredPane();
            this.createLayers(this.innerLayers);
            viewport.setContents(this.innerLayers);
            return viewport;
        },
        createPrintableLayers: function () {
            var layeredPane = new COM.draw2d.FreeformLayeredPane();
            layeredPane.add(new AGEF.AbrazosFreeformLayer(), COM.gef.LayerConstants.PRIMARY_LAYER);
            layeredPane.add(new COM.draw2d.ConnectionLayer(), COM.gef.LayerConstants.CONNECTION_LAYER);
            return layeredPane;
        },
    });
})();
/**
 * Created by xiongshilin on 2017/3/29.
 */
(function(){
    AGEF.AbrazosUnlimitedFreeformEditPart = function() {
        AGEF.AbrazosUnlimitedFreeformEditPart.superclass.constructor.call(this);
    };
    var superClass = COM.gef.AbstractGraphicalEditPart;
    COM.util.defineClass(AGEF.AbrazosUnlimitedFreeformEditPart, superClass, {
        createFigure: function(){
            var figure = new AGEF.AbrazosUnlimitedFreeformFigure(this.id);
            return figure;
        },
        createEditPolicies: function(){
            this.installEditPolicy(COM.gef.EditPolicy.LAYOUT_ROLE, new COM.gef.XYLayoutEditPolicy());
        },
        getDragTracker: function(request){
            return new COM.gef.CancelSelectionTracker(this);
        },
        refreshChildren: AGEF.functions.editPartRefreshChildren,
    });
})();

/**
 * Created by xiongshilin on 2017/3/29.
 */
(function(){
    AGEF.ComponentEditPolicy = function() {
        AGEF.ComponentEditPolicy.superclass.constructor.call(this);
    };
    var superClass = COM.gef.GraphicalEditPolicy;

    COM.util.defineClass(AGEF.ComponentEditPolicy, superClass, {
        getCommand:function(request){
            var model = this.getHost().getModel();
            if(request.getType() == AGEF.ChangeValueRequest.TYPE) {
                return COM.gef.Command.createCommand({
                    label: "change text",
                    execute: function(){
                        this.propertyName = request.getPropertyName();
                        this.oldValue = model.getPropertyValue(this.propertyName);
                        model.setPropertyValue(this.propertyName, request.getValue());
                    },
                    undo: function(){
                        model.setPropertyValue(this.propertyName, this.oldValue);
                    }
                });
            }
            return null;
        }
    });
})();
/**
 * Created by xiongshilin on 2017/3/24.
 */
(function(){
    AGEF.Widget = function(parent){
        this.domElement = null;
        this.parent = parent;
    };
    var superClass = Object;
    COM.util.defineClass(AGEF.Widget, superClass, {
        setDomElement:function(dom) {
            this.domElement = dom;
        },
        getDomElement:function() {
            return this.domElement;
        },
        getParent:function(){
            return this.parent;
        },
        setParent:function(parent){
            return this.parent = parent;
        },
        getLabel: Function.needOverride,
        createDomElement: Function.needOverride
    });
})();
/**
 * Created by xiongshilin on 2017/3/24.
 */
(function(){
    AGEF.Control = function(parent) {
        AGEF.Control.superclass.constructor.call(this, parent);
    };
    var superClass = AGEF.Widget;
    COM.util.defineClass(AGEF.Control, superClass, {
        // setX:function(value){
        //     COM.util.HTMLUtil.setX(this.domElement,value);
        // },
        // setY:function(value){
        //     COM.util.HTMLUtil.setY(this.domElement,value);
        // },
        // setWidth:Function.emptyFunction,
        // setHeight:Function.emptyFunction,
        // setBounds:function(bounds){
        //     COM.util.HTMLUtil.setBounds(this.domElement, bounds);
        // },
        // getX:Function.emptyFunction,
        // getY:Function.emptyFunction,
        // getWidth:function(){
        //     return COM.util.HTMLUtil.getElementWidth(this.domElement);
        // },
        // getHeight:function(){
        //     return COM.util.HTMLUtil.getElementHeight(this.domElement);
        // },

        //获取dom再浏览器中渲染的实际位置
        getBounds:function(){
            var bounds = COM.util.HTMLUtil.getBounds(this.domElement);
            var parentControlElement = this.getParent().getDomElement();
            var parentDomElement = this.domElement.parentElement;
            while(parentControlElement !== parentDomElement){
                var parentBounds = COM.util.HTMLUtil.getBounds(parentDomElement);
                bounds.x = bounds.x + parentBounds.x + 1;//(父容器内边框的高度) + 1（父容器边框）
                bounds.y = bounds.y + parentBounds.y + 1;//要坐标高度20（标题栏高度） + 1（父容器边框）
                parentDomElement = parentDomElement.parentElement;
            }
            return bounds;
        },

        setLayoutData : function(data){
            this.needLayoutFlag = true
            this.layoutData = data;
        },

        getLayoutData : function(){
            return this.layoutData;
        },

        needLayout : function(){
            return this.needLayoutFlag;
        },

        setLayouted : function(value){
            this.needLayoutFlag = !value;
        }

        // setSize: Function.emptyFunction

    });
})();
/**
 * Created by xiongshilin on 2017/3/24.
 */
(function(){
    AGEF.Composite = function(parent) {
        AGEF.Composite.superclass.constructor.call(this, parent);
        this.children = [];
    };
    var superClass = AGEF.Control;
    COM.util.defineClass(AGEF.Composite, superClass, {
        getChildren: function(){
            return this.children;
        },
        addChild: function(child, index) {
            if(arguments.length == 2) {
                this.children.splice(index, 0, child);
            } else {
                this.children.push(child);
            }
            child.setParent(this);
            this.appendDomChild(child.getDomElement());
        },
        appendDomChild: Function.needOverride,
        removeChild: function(child){
            COM.util.Array.removeItem(this.children, child);
            this.removeDomChild(child.getDomElement());
        },
        layoutChild: Function.emptyFunction,
        _childLayoutChanged : function(){
            return false;
        },
        removeDomChild: Function.needOverride,
        getChild: function(index) {
            if(0 < index && index < this.children.length) {
                return this.children[index];
            }
            return null;
        },
        clearChildren:function() {
            this.children = [];
        }
    });
})();
/**
 * Created by xiongshilin on 2017/3/28.
 */
(function(){
    AGEF.RootControl = function(){
        AGEF.RootControl.superclass.constructor.call(this, null);
    };
    var superClass = AGEF.Composite;
    COM.util.defineClass(AGEF.RootControl, superClass, {
        getLabel: function() {
            return "RootControl";
        },
        createDomElement: function() {
            var element = document.createElement("div");
            element.id = "rootcontrol";
            element.style.position="absolute";
            element.style.top="0px";
            element.style.left="0px";
            element.style.width="100%";
            element.style.height="100%";
            this.domElement = element;
        },
        setWidth:function(width) {
            if(this.domElement) {
                this.domElement.style.width = width + "px";
            }
        },
        setHeight:function(height) {
            if(this.domElement) {
                this.domElement.style.height = height + "px";
            }
        },
        setSize: function(width, height) {
            if(this.domElement) {
                this.domElement.style.width = width + "px";
                this.domElement.style.height = height + "px";
            }
        },
        appendDomChild: function(domChild) {
            COM.util.HTMLUtil.addChild(this.domElement, domChild);
        },
        removeDomChild: function(domChild) {
            COM.util.HTMLUtil.removeChild(domChild);
        },
        getDomElement: function(){
            if(!this.domElement) {
                this.createDomElement();
            }
            return this.domElement;
        }
    });
})();
/**
 * Created by xiongshilin on 2017/3/29.
 */
(function(){
    AGEF.ContentsControl = function(){
        AGEF.ContentsControl.superclass.constructor.call(this, null);
    };
    var superClass = AGEF.Composite;
    COM.util.defineClass(AGEF.ContentsControl, superClass, {
        getLabel: function() {
            return "DefaultContentsControl";
        },
        createDomElement: function() {
            var element = document.createElement("div");
            element.id = "contentscontrol";
            element.style.position="relative";
            element.style.top="0px";
            element.style.left="0px";
            element.style.width="100%";
            element.style.height="100%";
            this.domElement = element;
        },
        setWidth:function(width) {
            if(this.domElement) {
                this.domElement.style.width = width + "px";
            }
        },
        getWidth: function() {
            if(this.domElement) {
                return COM.util.HTMLUtil.getElementWidth(this.domElement);
            }
        },
        setHeight:function(height) {
            if(this.domElement) {
                this.domElement.style.height = height + "px";
            }
        },
        getHeight: function() {
            if(this.domElement) {
                return COM.util.HTMLUtil.getElementHeight(this.domElement);
            }
        },
        setSize: function(width, height) {
            if(this.domElement) {
                this.domElement.style.width = width + "px";
                this.domElement.style.height = height + "px";
            }
        },
        appendDomChild: function(domChild) {
            COM.util.HTMLUtil.addChild(this.domElement, domChild);
        },
        removeDomChild: function(domChild) {
            COM.util.HTMLUtil.removeChild(domChild);
        },
        getDomElement: function(){
            if(!this.domElement) {
                this.createDomElement();
            }
            return this.domElement;
        },
        layoutChild : function(child){
            var childDom = child.getDomElement();
            var layoutData = child.getLayoutData();
            if(layoutData){
                var css = {"display":"block", "position":"absolute", "left":layoutData.x + 'px', "top":layoutData.y + 'px'};
                if(layoutData.width >= 0) {
                    css.width = layoutData.width + 'px';
                }
                if(layoutData.height >= 0) {
                    css.height = layoutData.height + 'px';
                }
                $(childDom).css(css);
            }
            if(child._afterLayout){
                child._afterLayout();
            }
        }
    });
})();
/**
 * Created by xiongshilin on 2017/3/23.
 */
(function(){
    AGEF.Map = function() {
        this.internalMap = {};
    };

    COM.util.defineClass(AGEF.Map, {
        isEmpty : function(){
            for(var i in this.internalMap){
                if(this.internalMap.hasOwnProperty(i))
                    return false;
            }
            return true;
        },
        hasKey : function(key){
            return this.internalMap.hasOwnProperty(key);
        },
        put : function(key,value){
            this.internalMap[key]=value;
        },
        getValue : function(key){
            return this.internalMap[key];
        },
        getKeys : function(){
            var keys = [];
            for(var i in this.internalMap){
                if(this.internalMap.hasOwnProperty(i))
                    keys.push(i);
            }
            return keys;
        },
        getValues : function(){
            var v = [];
            for(var i in this.internalMap){
                if(this.internalMap.hasOwnProperty(i))
                    v.push(this.internalMap[i]);
            }
            return v;
        },
        remove : function(key){
            delete this.internalMap[key];
        },
        clear : function(){
            for(var i in this.internalMap){
                if(this.internalMap.hasOwnProperty(i))
                    delete this.internalMap[i];
            }
        },
        each : function(fun,obj){
            var keys = this.getKeys();
            for(var i=0,len=keys.length;i<len;i++){
                var key = keys[i];
                var flag = fun.call(obj,this.getValue(key),key,this);
                if(flag === false) break;
            }
        },
        filter : function(fn,obj){
            var res = [];
            var keys = this.getKeys();
            for(var i=0,len=keys.length;i<len;i++){
                var key = keys[i];
                if(fn.call(obj,this.getValue(key),key,this))
                    res.push(this[i]);
            }
            return res;
        }
    });
})();
/**
 * Created by xiongshilin on 2017/3/22.
 */
(function (){
    AGEF.PropertySource = function(){};
    AGEF.PropertySource.prototype.getPropertyDescriptors = Function.needOverride;
    AGEF.PropertySource.prototype.getPropertyDescriptor = Function.needOverride;
    AGEF.PropertySource.prototype.getPropertyValue = Function.needOverride;
    AGEF.PropertySource.prototype.setPropertyValue = Function.needOverride;
    AGEF.PropertySource.prototype.isPropertySet = Function.needOverride;
    AGEF.PropertySource.prototype.addPropertyDescriptor = Function.needOverride;
    AGEF.PropertySource.prototype.removePropertyDescriptor = Function.needOverride;
})();
/**
 * Created by xiongshilin on 2017/3/22.
 */
(function (){
    AGEF.BaseModel = function(){
        AGEF.BaseModel.superclass.constructor.call(this);
        this.listeners = new AGEF.PropertyChangeSupport(this);
        this.propertyDescriptors = new AGEF.Map;//new Array();
        this.initModel();
    };
    var superClass = AGEF.PropertySource;
    AGEF.BaseModel.PROPERTY_LAYOUTDATA = "layoutdata";
    COM.util.defineClass(AGEF.BaseModel, superClass, {
        initModel: function(){
            var pd = new  AGEF.PropertyDescriptor(AGEF.BaseModel.PROPERTY_LAYOUTDATA, {}, "", true);
            pd.setTitle("布局数据");
            pd.setHint("布局数据");
            this.addPropertyDescriptor(pd);    
        },
        addPropertyChangeListener: function (listener) {
            this.listeners.addPropertyChangeListener(listener);
        },
        removePropertyChangeListener: function (listener) {
            this.listeners.removePropertyChangeListener(listener);
        },
        firePropertyChange: function (type, prop, oldValue, newValue) {
            if(AGEF.PropertyChangeEvent.UPDATE_EVENT == type){
                this.listeners.firePropertyChange(prop, oldValue, newValue);
            } else if(AGEF.PropertyChangeEvent.ADD_EVENT == type){
                this.listeners.firePropertyAdd(prop, newValue);
            } else if(AGEF.PropertyChangeEvent.DELETE_EVENT == type){
                this.listeners.firePropertyDelete(prop);
            } else{
                throw Error("没有指定模型变化事件类型");
            }
        },
        addPropertyDescriptor: function(newProp){
            if(!COM.util.isInstanceOf(newProp, AGEF.PropertyDescriptor)){
                throw "newProp is invalid";
            }
            var prop = this.propertyDescriptors.getValue(newProp.getName());
            if(prop) {
                COM.util.ObjUtil.copyProperty(prop, newProp);
                this.firePropertyChange(AGEF.PropertyChangeEvent.UPDATE_EVENT, prop.getName(), prop.getOldValue(), newProp.getValue());
            } else {
                this.propertyDescriptors.put(newProp.getName(), newProp);
                this.firePropertyChange(AGEF.PropertyChangeEvent.ADD_EVENT, newProp.getName(), null, newProp.getValue());
            }
        },
        removePropertyDescriptor: function(name){
            if(this.propertyDescriptors.hasKey(name)){
                this.propertyDescriptors.remove(name);
                this.firePropertyChange(AGEF.PropertyChangeEvent.DELETE_EVENT, name);
            }
        },
        setPropertyValue: function(propName, value) {
            var propertyDescriptor = this.propertyDescriptors.getValue(propName);
            if(propertyDescriptor) {
                var oldValue = propertyDescriptor.getValue();
                propertyDescriptor.setValue(value);
                this.firePropertyChange(AGEF.PropertyChangeEvent.UPDATE_EVENT, propertyDescriptor.getName(), oldValue, value);
            }
        },
        getPropertyValue: function(propName) {
            var propertyDescripter = this.propertyDescriptors.getValue(propName);
            if(propertyDescripter) {
                return propertyDescripter.getValue();
            }
            return null;
        },
        getPropertyDescriptor: function(name){
            return this.propertyDescriptors.getValue(name);
        },
        getPropertyDescriptors: function(){
            return this.propertyDescriptors.getValues();
        },
        isPropertySet: function(propName) {
            return this.propertyDescriptors.hasKey(propName);
        },
        serialize: function(){
            var jsonObject={"modelType":this._getModelType(), "id" : this.getID()};
            jsonObject[AGEF.BaseModel.PROPERTY_LAYOUTDATA]=this.getPropertyDescriptor(AGEF.BaseModel.PROPERTY_LAYOUTDATA).serialize();
            return COM.util.ObjUtil.stringify(jsonObject);
        },
        deserialize: function(jsonString){
            var jsonObject=COM.util.ObjUtil.parseJSON(jsonString);
            this.id = jsonObject.id;
            var newProp=new AGEF.PropertyDescriptor();
            newProp.deserialize(jsonObject[AGEF.BaseModel.PROPERTY_LAYOUTDATA]);
            this.propertyDescriptors.put(newProp.getName(),newProp);
            // -----  XXX 兼容性代码，之后去掉
            if(jsonObject['bounds']){
                var newProp=null;
                newProp=new AGEF.PropertyDescriptor();
                newProp.deserialize(jsonObject['bounds']);
                var layoutdata=new COM.draw2d.Rectangle();
                COM.util.ObjUtil.copyProperty(layoutdata,newProp.getValue());
                newProp.setName(AGEF.BaseModel.PROPERTY_LAYOUTDATA);
                newProp.setValue(layoutdata);
                newProp.setEditable(true);
                this.propertyDescriptors.put(newProp.getName(),newProp);
            }
            // ------
            return jsonObject;
        },

        setLayoutData: function(data) {
            this.setPropertyValue(AGEF.BaseModel.PROPERTY_LAYOUTDATA, data);
        },
        getLayoutData: function() {
            return this.getPropertyValue(AGEF.BaseModel.PROPERTY_LAYOUTDATA);
        },
        clone: function() {
            var newModel = new this.constructor();
            newModel.deserialize(this.serialize());
            return newModel;
        },

        _deserializeProp : function(jsonObject, name){
            if(jsonObject[name]){
                var newProp=null;
                newProp=new AGEF.PropertyDescriptor();
                newProp.deserialize(jsonObject[name]);
                this.propertyDescriptors.put(newProp.getName(),newProp);
            }
        },

        _getModelType : Function.needOverride,

        getID : function(){
            this.id || (this.id = COM.util.ObjUtil.generateID());
            return this.id;
        },

        getType: Function.emptyFunction
    });
})();
/**
 * Created by xiongshilin on 2017/3/23.
 */
(function(){
    AGEF.PropertyChangeEvent = function(type, source, propName, oldValue, newValue) {
        AGEF.PropertyChangeEvent.superclass.constructor.call(this, source, propName, oldValue, newValue);
        this.type = type;
    };

    COM.util.defineClass(AGEF.PropertyChangeEvent, COM.draw2d.PropertyChangeEvent, {
        setType: function(type){
            return this.type = type;
        },
        getType: function(){
            return this.type;
        }
    });

    //属性变化事件类型（更新，新增，删除）
    AGEF.PropertyChangeEvent.UPDATE_EVENT = "update";
    AGEF.PropertyChangeEvent.ADD_EVENT = "add";
    AGEF.PropertyChangeEvent.DELETE_EVENT = "delete";

    AGEF.IndexedPropertyChangeEvent = function(type, source,propertyName,oldValue,newValue,index){
        COM.model.IndexedPropertyChangeEvent.superclass.constructor.call(this,type,source,propertyName,oldValue,newValue);
        this.index = index;
    };

    COM.util.defineClass(AGEF.IndexedPropertyChangeEvent, AGEF.PropertyChangeEvent, {
        getIndex: function(){
            return this.index;
        }
    });

    AGEF.PropertyChangeSupport = function(source){
        AGEF.PropertyChangeSupport.superclass.constructor.call(this);
        this.listeners;
        this.source = source;
    };

    COM.util.defineClass(AGEF.PropertyChangeSupport, COM.draw2d.PropertyChangeSupport, {
        firePropertyChange: function(arg1,arg2,arg3){
            if(arguments.length == 3){
                var propertyName = arg1;
                var oldValue = arg2;
                var newValue = arg3;
                if (oldValue != null && newValue != null && oldValue == newValue) {
                    return;
                }
                this.firePropertyChange(new AGEF.PropertyChangeEvent(AGEF.PropertyChangeEvent.UPDATE_EVENT, this.source, propertyName,oldValue, newValue));
            }else{
                var evt = arg1;
                var oldValue = evt.getOldValue();
                var newValue = evt.getNewValue();
                var propertyName = evt.getPropertyName();
                if (oldValue != null && newValue != null && oldValue == newValue) {
                    return;
                }
                if (this.listeners != null) {
                    for (var i = 0; i < this.listeners.length; i++) {
                        this.listeners[i].propertyChange(evt);
                    }
                }
                if (this.children != null && propertyName != null) {
                    var child = this.children.get(propertyName);
                    if (child != null) {
                        child.firePropertyChange(evt);
                    }
                }
            }
        },
        firePropertyAdd: function(propertyName, newValue) {
            if(!propertyName){
                return;
            }
            this.firePropertyChange(new AGEF.PropertyChangeEvent(AGEF.PropertyChangeEvent.ADD_EVENT, this.source, propertyName, null, newValue));
        },
        firePropertyDelete: function(propertyName) {
            this.firePropertyChange(new AGEF.PropertyChangeEvent(AGEF.PropertyChangeEvent.ADD_EVENT, this.source, propertyName, null, null));
        },
        fireIndexedPropertyChange: function(propertyName,index,oldValue,newValue){
            if(oldValue == newValue){
                return;
            }
            this.firePropertyChange(new AGEF.IndexedPropertyChangeEvent(AGEF.PropertyChangeEvent.UPDATE_EVENT, this.source, propertyName, oldValue, newValue, index));
        }
    });
})();
/**
 * Created by xiongshilin on 2017/3/22.
 */
(function (){
    AGEF.PropertyDescriptor = function(name, value, defaultValue, editable){
        AGEF.PropertyDescriptor.superclass.constructor.call(this);
        this.key = null;
        this.name = name;
        this.title = name;
        this.hint = name;
        this.value = value;
        this.defaultValue = defaultValue;
        this.editable = editable;
        this.editorType = null;
        this.serializable = true;
        this.additional = "";
    };
    var superClass = Object;
    COM.util.defineClass(AGEF.PropertyDescriptor, superClass, {
        getKey: function(){
            return this.key;
        },
        getName: function(){
            return this.name;
        },
        getTitle: function(){
            return this.title;
        },
        getHint: function() {
            return this.hint;
        },
        getValue: function() {
            return this.value;
        },
        getDefaultValue: function() {
            return this.defaultValue;
        },
        getEditorType: function() {
            return this.editorType;
        },
        isEditable: function() {
            return this.editable
        },
        isSerializable: function() {
            return this.serializable
        },
        setKey: function(key){
            this.key = key;
        },
        setName: function(name){
            this.name = name;
        },
        setTitle: function(title){
            this.title = title;
        },
        setHint: function(hint) {
            this.hint = hint;
        },
        setValue: function(value) {
            this.value = value;
        },
        setDefaultValue: function(defaultValue) {
            this.defaultValue = defaultValue;
        },
        setEditorType: function(editorType) {
            this.editorType = editorType;
        },
        setEditable: function(editable) { 
            this.editable = editable;
        },
        setSerializable: function(serializable) {
            this.serializable = serializable;
        },
        setAdditional : function(additional){
            this.additional = additional;
        },
        getAdditional : function(){
            return this.additional;
        },
        serialize: function(){
            var jsonObject = {};
            COM.util.ObjUtil.copyProperty(jsonObject, this);
            return COM.util.ObjUtil.stringify(jsonObject);
        },
        deserialize: function(jsonString){
            if(jsonString){
                var jsonObject = COM.util.ObjUtil.parseJSON(jsonString);
                COM.util.ObjUtil.copyProperty(this, jsonObject);
            }
        }
    });
})();
/**
 * Created by xiongshilin on 2017/3/22.
 */
(function(w){
    var DOMUtil = {};
    DOMUtil.setX = function(element, value) {
        $(element).css({'left':value});
    };

    DOMUtil.setY = function(element, value) {
        $(element).css({'top':value});
    };

    DOMUtil.getX = function(element) {
        if(element){
            return $(element).position().left;
        }
    };

    DOMUtil.getY = function(element) {
        if(element){
            return $(element).position().top;
        }
    };

    DOMUtil.getXY = function(element) {
        var xy = {};
        if(element) {
            xy.x = DOMUtil.getX(element);
            xy.y = DOMUtil.getY(element);
        }
        return xy;
    };

    DOMUtil.setElementWidth = function(element, value) {
        $(element).css({'width':value});
    };

    DOMUtil.setElementHeight = function(element, value) {
        $(element).css({'height':value});
    };

    DOMUtil.getElementWidth = function(element){
        return $(element).outerWidth();
    };

    DOMUtil.getElementHeight = function(element){
        return $(element).outerHeight();
    };

    DOMUtil.getBounds = function(element) {
        var bounds = {};
        bounds.x = DOMUtil.getX(element);
        bounds.y = DOMUtil.getY(element);
        bounds.width = DOMUtil.getElementWidth(element);
        bounds.height = DOMUtil.getElementHeight(element);

        return bounds;
    };

    DOMUtil.setBounds = function(element, bounds) {
        DOMUtil.setX(element, bounds.x);
        DOMUtil.setY(element, bounds.y);
        DOMUtil.setElementWidth(element, bounds.width);
        DOMUtil.setElementHeight(element, bounds.height);
    };

    DOMUtil.getElementById = function(id) {
        if(!id) {
            throw "the parameter 'id' is not defined";
        }
        return $(id);
    };

    DOMUtil.getJqueryDOM = function(element) {
        if(!element) {
            throw "the parameter 'element' is not defined";
        }
        return $(element);
    };

    DOMUtil.createELement = function(string) {
        return $(string);
    };

    DOMUtil.addChild = function(parent,child) {
        return $(parent).append(child);
    };
    DOMUtil.removeChild = function(child) {
        $(child).remove();
    };
    DOMUtil.getChildren = function(parent, selector) {
        return $(parent).find(selector);
    };
    DOMUtil.clearChildren = function (element) {
        $(element).empty();
    } ;
    DOMUtil.bindClick = function(child, fun) {
        $(child).click(fun);
    };
    DOMUtil.domToString = function(element, self) {
        if(self) {
            return $("div").append(element)[0].innerHTML;
        } else {
            return element.innerHTML;
        }
    };
    DOMUtil.createJSTree = function(element, options) {
        if(element) {
            return $(element).jstree(options);
        }
    };
    DOMUtil.hasChild = function(element, child) {
        return $(element).find(child).length > 0;
    }
    w.COM.util.HTMLUtil = DOMUtil;
})(window);

/**
 * Created by xiongshilin on 2017/3/22.
 */
(function (w) {
    var ObjectUtil = {};
    ObjectUtil.stringify = function (jsonObject) {
        return JSON.stringify(jsonObject);
    };

    ObjectUtil.parseJSON = function (jsonString) {
        return JSON.parse(jsonString);
        //return $.parseJSON( jsonString );
    };

    ObjectUtil.copyProperty = function (target, source) {
        for (var prop in source) {
            if (typeof (source[prop]) != "function") {
                target[prop] = source[prop];
            };
        }
    };
    ObjectUtil.S4 = function () {
        return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
    };
    ObjectUtil.guid = function () {
        return (this.S4() + this.S4() + "-" + this.S4() + "-" + this.S4() + "-" + this.S4() + "-" + this.S4() + this.S4() + this.S4());
    };

    ObjectUtil.generateID = function () {
        return Math.round(Math.random() * 0xFFFFFFFF).toString(32) + Math.round(Math.random() * 0xFFFFFFFF).toString(32);
    };

    (function (domain) {
        function _override(o, overrides, exceptions) {
            for (var p in overrides) {
                if (exceptions && exceptions[p]) continue;
                o[p] = overrides[p];
            }
        };

        if (!domain.extend) {
            domain.defineClass = function (thisclass, superclass, override) {
                if (typeof superclass !== 'function' && typeof superclass === 'object' && typeof override === 'undefined') {
                    override = superclass;
                    superclass = Object;
                }
                var overrides = [];
                if(Object.prototype.toString.call(override) == "[object Array]"){
                    overrides = override;
                }else{
                    overrides.push(override);
                }
                //check
                if (null == superclass) {
                    throw 'no superclass, you can use Object or do not give the superclass arg.';
                }
                //perform
                var f = new Function();
                f.prototype = superclass.prototype;
                var p = thisclass.prototype = new f();
                p.constructor = thisclass;
                thisclass.superclass = superclass.prototype;
                if(overrides){
                    for (var i = 0; i < overrides.length; i++) {
                        var o = overrides[i];
                        _override(thisclass.prototype, o);
                    }
                }
            };
        }
    })(ObjectUtil);

    w.COM.util.ObjUtil = ObjectUtil;
})(window);
/**
 * Created by xiongshilin on 2017/4/1.
 */
(function() {
    AGEF.AbrazosGroup = function() {};
    AGEF.AbrazosGroup.prototype.createControl = Function.needOverride;
    AGEF.AbrazosGroup.prototype.setControl = Function.needOverride;
    AGEF.AbrazosGroup.prototype.getControl = Function.needOverride;
    AGEF.AbrazosGroup.prototype.addChild = Function.needOverride;
    AGEF.AbrazosGroup.prototype.removeChild = Function.needOverride;
})();
/**
 * Created by xiongshilin on 2017/4/1.
 */
(function() {
    AGEF.AbrazosViewer = function() {};
    AGEF.AbrazosViewer.prototype.createControl = Function.needOverride;
    AGEF.AbrazosViewer.prototype.setControl = Function.needOverride;
    AGEF.AbrazosViewer.prototype.getControl = Function.needOverride;
    AGEF.AbrazosViewer.prototype.selectionChanged = Function.needOverride;
    AGEF.AbrazosViewer.prototype.addSelectionListener = Function.needOverride;
    AGEF.AbrazosViewer.prototype.fireSelectionChange = Function.needOverride;
    AGEF.AbrazosViewer.prototype.removeSelectionListener = Function.needOverride;
    AGEF.AbrazosViewer.prototype.setContents = Function.needOverride;
})();
/**
 * Created by xiongshilin on 2017/4/1.
 */
(function() {
    AGEF.AbstractAbrazosViewer = function(container) {
        AGEF.AbstractAbrazosViewer.superclass.constructor.call(this);
        this.control = null;
        this.container = container;
        this.selectionDispatcher = null;
    };
    var superClass = AGEF.AbrazosViewer;
    COM.util.defineClass(AGEF.AbstractAbrazosViewer, superClass, {
        getContainer: function() {
            return this.container;
        },
        setContainer: function(container) {
            this.container = container;
        },
        createControl: function() {
            //todo
        },
        setControl: function(control) {
            this.control = control;
        },
        getControl: function() {
            return this.control;
        },
        addSelectionDispatcher: function(dispatcher) {
            this.selectionDispatcher = dispatcher;
        },
        setContents: function(contents) {
        }
    });
})();
/**
 * Created by xiongshilin on 2017/4/1.
 */
(function() {
    AGEF.PaletteGroupModel = function(label) {
        AGEF.PaletteGroupModel.superclass.constructor.call(this);
        this.label = label;
    };
    AGEF.PaletteGroupModel.PROPERTY_TOOLMODEL = "toolModels";
    AGEF.PaletteGroupModel.PROPERTY_CONFIG = "config";
    var superClass = AGEF.BaseModel;
    COM.util.defineClass(AGEF.PaletteGroupModel, superClass, {
        initModel: function() {
            var pToolModel = new AGEF.PropertyDescriptor(AGEF.PaletteGroupModel.PROPERTY_TOOLMODEL, []);
            var config = new AGEF.PropertyDescriptor(AGEF.PaletteGroupModel.PROPERTY_CONFIG, "");
            this.addPropertyDescriptor(pToolModel);
            this.addPropertyDescriptor(config);
        },
        addToolModel: function(pToolModel) {
            this.getPropertyValue(AGEF.PaletteGroupModel.PROPERTY_TOOLMODEL).push(pToolModel);
        },
        getToolModels: function() {
            return this.getPropertyValue(AGEF.PaletteGroupModel.PROPERTY_TOOLMODEL);
        },
        setConfig: function(config) {
            this.setPropertyValue(AGEF.PaletteGroupModel.PROPERTY_CONFIG, config);
        },
        getConfig:function(){
            return this.getPropertyValue(AGEF.PaletteGroupModel.PROPERTY_CONFIG);
        },
        setToolModels: function(toolModels) {
            this.setPropertyValue(AGEF.PaletteGroupModel.PROPERTY_TOOLMODEL, toolModels);
        },
        getLabel: function() {
            return "defaultPaletteGroup";
        }
    });
})();
/**
 * Created by xiongshilin on 2017/4/1.
 */
(function() {
    AGEF.PaletteToolModel = function() {
        AGEF.PaletteToolModel.superclass.constructor.call(this);
        this.toolType = AGEF.AbrazosCreationTool.LABEL;//默认为选择工具类型
        this.model = null;
        this.config = null;
        this.label = "defaultPaletteTool";
    };

    COM.util.defineClass(AGEF.PaletteToolModel, Object, {
        initModel: function() {

        },
        setToolType: function(toolType) {
            this.toolType = toolType;
        },
        getToolType: function() {
            return this.toolType;
        },
        setModel: function(model) {
            this.model =model;
        },
        getModel: function() {
            return this.model;
        },
        getLabel: function() {
            return this.label;
        },
        setLabel : function(label){
            this.label = label;
        },
        setConfig: function(config) {
            this.config = config;
        },
        getConfig: function() {
            return this.config;
        }
    });
})();
/**
 * Created by xiongshilin on 2017/4/1.
 */
(function() {
    AGEF.PaletteGroup = function() {
        AGEF.PaletteGroup.superclass.constructor.call(this);
        this.control = null;
    };
    AGEF.PaletteGroup.LABEL = "defaultPaletteGroup";
    var superClass = AGEF.AbrazosGroup;
    COM.util.defineClass(AGEF.PaletteGroup, superClass, {
        createControl: function(model) {
            var control = COM.util.HTMLUtil.createELement("<div class='panel panel-default' style='margin-bottom: 0;border-bottom: none;min-height: 150px;'><div class='panel-heading' style='font-weight: bold;'>"+ model.getConfig().text +"<i class='iconfont "+model.getConfig().icon+"' style='font-size: 1px;'></i></div><div class='panel-body' style='padding: 22px 18px 0 18px;display:flex;display:-webkit-flex;flex-direction:row;flex-wrap:wrap;justify-content: space-around;'></div></div>");
            this.control = control[0];
        },
        getControl: function() {
            return this.control;
        },
        addChild: function(child) {
            COM.util.HTMLUtil.getChildren(this.control, ".panel-body").append(child.getControl());
        }
    });
})();

/**
 * Created by xiongshilin on 2017/4/1.
 */
(function() {
    AGEF.ToolEntry = function() {
        AGEF.ToolEntry.superclass.constructor.call(this);
    };
    AGEF.ToolEntry.LABEL = "defaultPaletteTool";
    COM.util.defineClass(AGEF.ToolEntry, Object, {
        createControl: function(model) {
            var control = null;
            if(model.getText()) {
                control = COM.util.HTMLUtil.createELement('<button type="button" class="btn btn-default col-sm-6">'+model.getText()+'</button>');
            } else {
                control = COM.util.HTMLUtil.createELement('<button type="button" class="btn btn-default col-sm-6"><span class="glyphicon glyphicon-hand-up toggle"></span></button>');
            }
            this.control = control[0];
        },
        getControl: function() {
            return this.control;
        },
        bindActionHandler: function(handler) {
            COM.util.HTMLUtil.bindClick(this.control, function() {
                handler();
            });
        }
    });
})();
/**
 * Created by xiongshilin on 2017/4/1.
 */
(function(){
    AGEF.PaletteViewer = function(container) {
        AGEF.PaletteViewer.superclass.constructor.call(this, container);
        this.paletteChildControls = new COM.draw2d.Map();
        this.tools = new COM.draw2d.Map();//存储GEF概念中的tool：比如SelectionTool、CreateTool
        this.createControl();
    };
    AGEF.PaletteViewer.SELECTION_TOOL="selectionTool";
    var superClass = AGEF.AbstractAbrazosViewer;
    COM.util.defineClass(AGEF.PaletteViewer, superClass, {
        registerControl: function(label, control) {
            if(label) {
                this.paletteChildControls.put(label, control);
            } else {
                throw new Error('未指定控件的标签');
            }
        },
        registerTool: function(label, tool) {
            if(label) {
                this.tools.put(label, tool);
            } else {
                throw new Error('未指定Tool的标签');
            }
        },
        getControlInstance: function(label) {
            var control = this.paletteChildControls.get(label);
            if(control) {
                return new control();
            }
            return null;
        },
        getToolInstance: function(label) {
            var tool = this.tools.get(label);
            if(tool) {
                return new tool();
            }
            return null;
        },
        createControl: function() {
            if(this.getContainer()) {
                this.control = document.createElement('div');
                this.control.style.position = 'relative';
                this.control.style.width = "100%";
                //this.control.style.height = "100%";
                //this.control.style.backgroundColor = "#686868";
                this.getContainer().appendChild(this.control);
            }
        },
        addPaletteGroup: function(groupModel) {
            var group = this.getControlInstance(groupModel.getLabel()), toolModels = groupModel.getPropertyValue(AGEF.PaletteGroupModel.PROPERTY_TOOLMODEL);
            group.createControl(groupModel);
            this.control.appendChild(group.getControl());
            for(var i in toolModels) {
                var tool = this.createToolEntry(toolModels[i]);
                group.addChild(tool);
            }
        },
        createToolEntry: function(toolEntryModel) {
            var toolControl = this.getControlInstance(toolEntryModel.getLabel());
            toolControl.createControl(toolEntryModel);//fireSelectionChange
            toolControl.bindActionHandler(function(){
                var tool = this.getToolInstance(toolEntryModel.getToolType());
                if(tool.setBeingCreatedModel){
                    tool.setBeingCreatedModel(toolEntryModel.getModel().clone());
                }
                this.selectionDispatcher.notifyChange(AGEF.PaletteViewer.SELECTION_TOOL, {"activatedTool":tool});
            }.bind(this), toolEntryModel);
            return toolControl;
        },
        setContents: function(contents) {
            for(var i in contents) {
                this.addPaletteGroup(contents[i]);
            }
        }
    });
})();
/**
 * Created by xiongshilin on 2017/4/1.
 */
(function() {
    AGEF.PropertyEditor = function(propDescriptor) {
        AGEF.PropertyEditor.superclass.constructor.call(this);
        this.control = null;
        this.propDescriptor = propDescriptor;
    };
    var superClass = Object;
    COM.util.defineClass(AGEF.PropertyEditor, superClass, {
        createControl: Function.needOverride,
        getControl: function() {
            return this.control;
        },
        setValue: Function.needOverride,
        bindChangeHandler: Function.needOverride
    });
})();

/**
 * Created by xiongshilin on 2017/4/1.
 */
(function() {
    AGEF.PropertyViewer = function(container) {
        AGEF.PropertyViewer.superclass.constructor.call(this, container);
        this.propertyControls = new COM.draw2d.Map();
        this.settingGroups = new AGEF.Map();
        this.currentEditors = new AGEF.Map();
        this.currentEditPart = null;
        this.createControl();
    };
    var superClass = AGEF.AbstractAbrazosViewer;
    COM.util.defineClass(AGEF.PropertyViewer, superClass, {
        registerControl: function(label, propEditor) {
            if(label) {
                this.propertyControls.put(label, propEditor);
            } else {
                throw new Error('未指定编辑器标签');
            }
        },
        unregisterControl: function(label) {
            if(label) {
                this.propertyControls.remove(label);
            }
        },
        getControlInstance: function(label, arg) {
            var propEditor = this.propertyControls.get(label);
            if(propEditor) {
                return new propEditor(arg);
            }
            return null;
        },
        createControl: function() {
            if(this.getContainer()) {
                this.control = document.createElement('div');
                this.control.style.position = 'relative';
                this.control.style.width = "100%";
                this.control.style.height = "-webkit-calc(100% - 52px)";
                this.control.style.height = "-moz-calc(100% - 52px)";
                this.control.style.height = "calc(100% - 52px)";
                //this.control.style.backgroundColor = "#668899";
                this.control.style.paddingBottom = "10px";
                this.control.style.overflow = "auto";
                this.getContainer().appendChild(this.control);
            }
        },
        clearGroupChidren: function() {
            this.settingGroups.each(function(group){
                group.clearChildren();
            });
        },
        refresh: function() {
            this.clearGroupChidren();
            COM.util.HTMLUtil.clearChildren(this.control);
            if(this.currentEditPart.getModel()) {
                var properties = this.currentEditPart.getModel().getPropertyDescriptors();
                for(var i in properties) {
                    var property = properties[i];
                    if(property.isEditable() && property.getEditorType()) {
                        var editorType = property.getEditorType(), labels = editorType.split("."),
                        ownerGroup = this.settingGroups.getValue(labels[0]),
                        editor = this.getControlInstance(labels[1], property);
                        if(editor){
                            this.currentEditors.put(property.getName(), editor);
                            editor.createControl(property);
                            editor.bindChangeHandler(function(request) {
                                var command = this.currentEditPart.getCommand(request);
                                this.currentEditPart.getViewer().getEditDomain().getCommandStack().execute(command);
                            }.bind(this));
                            ownerGroup.addChild(editor);
                            this.control.appendChild(ownerGroup.getControl());
                        }else{
                            console.warn("属性编辑器： " + labels[1] + " 对应的编辑器实例没有找到");
                        }
                    }
                }
            }
        },
        addSelectionDispatcher: function(dispatcher) {
            AGEF.PropertyViewer.superclass.addSelectionDispatcher.call(this, dispatcher);
            this.selectionDispatcher.addListener(AGEF.AbrazosGraphicalViewerImpl.SELECTION_GRAPHICAL, {update: function(arg) {
                if(arg && arg.selection) {
                    this.targetEditPartChanged(arg.selection[0]);
                } else {
                    COM.util.HTMLUtil.clearChildren(this.control);
                }
            }.bind(this)});
        },
        targetEditPartChanged: function(targetEditPart) {
            if(this.currentEditPart == targetEditPart) {
                return;
            }
            if(this.currentEditPart != null) {
                this.currentEditPart.getModel().removePropertyChangeListener(this);//移除之前模型上注册的监听器
            }
            this.currentEditPart = targetEditPart;
            this.currentEditPart.getModel().addPropertyChangeListener(this);
            this.refresh();
        },
        setContents: function(contents) {
            for(var i in contents) {
                var group = this.getControlInstance(contents[i].getLabel());
                group.createControl(contents[i]);
                this.settingGroups.put(contents[i].getID(), group);
            }
        },
        propertyChange: function(evt) {
            var editor = this.currentEditors.getValue(evt.getPropertyName());
            if(editor) {
                editor.setValue(evt.getNewValue());
            }
        }
    });
})();
/**
 * Created by xiongshilin on 2017/4/1.
 */
(function() {
    AGEF.PropertyGroupModel = function() {
        AGEF.PaletteGroupModel.superclass.constructor.call(this);
    };
    AGEF.PropertyGroupModel.CONFIG = "config";
    AGEF.PropertyGroupModel.ID = "groupID";
    var superClass = AGEF.BaseModel;
    COM.util.defineClass(AGEF.PropertyGroupModel, superClass, {
        initModel: function() {
            var config = new AGEF.PropertyDescriptor(AGEF.PropertyGroupModel.CONFIG, "");
            var id = new AGEF.PropertyDescriptor(AGEF.PropertyGroupModel.ID, "");
            this.addPropertyDescriptor(config);
            this.addPropertyDescriptor(id);
        },
        setConfig: function(config) {
            this.setPropertyValue(AGEF.PropertyGroupModel.CONFIG, config);
        },
        getConfig:function(){
            return this.getPropertyValue(AGEF.PropertyGroupModel.CONFIG);
        },
        setID: function(id) {
            this.setPropertyValue(AGEF.PropertyGroupModel.ID, id);
        },
        getID: function() {
            return this.getPropertyValue(AGEF.PropertyGroupModel.ID);
        },
        getLabel: function() {
            return "defaultPropertyGroup";
        }
    });
})();
/**
 * Created by xiongshilin on 2017/4/1.
 */
(function() {
    AGEF.PropertyGroup = function() {
        AGEF.PropertyGroup.superclass.constructor.call(this);
        this.control = null;
    };
    AGEF.PropertyGroup.LABEL = "defaultPropertyGroup";
    var superClass = AGEF.AbrazosGroup;
    COM.util.defineClass(AGEF.PropertyGroup, superClass, {
        createControl: function(model) {
            var control = COM.util.HTMLUtil.createELement("<div class='panel panel-default' style='border: none;margin-bottom: 0;'><div class='panel-heading' style='border-bottom: 1px solid #ddd;'><i class='iconfont "+model.getConfig().icon+"' style='margin-right:10px;position:relative;top:2px;'></i>"+ model.getConfig().text +"<i class='iconfont icon-xia rtx' style='position: absolute;right: 22px;'></i></div><div class='panel-body' style='border-bottom: 1px solid #ddd;padding:18px 18px 7px 20px;'></div></div>");
            this.control = control[0];
        },
        getControl: function() {
            var panelFlag = true;
            $(this.control).find('.rtx').click(function(){
                if(panelFlag){
                    $(this).parent().parent().find('.panel-body').css('display','none');
                    $(this).removeClass('icon-xia').addClass('icon-right');
                    panelFlag = false;
                }else{
                    $(this).parent().parent().find('.panel-body').css('display','block');
                    $(this).removeClass('icon-right').addClass('icon-xia');
                    panelFlag = true;
                }
            });
            return this.control;
        },
        addChild: function(child) {
            COM.util.HTMLUtil.getChildren(this.control, ".panel-body").append(child.getControl());
        },
        clearChildren: function() {
            var panelBody = COM.util.HTMLUtil.getChildren(this.control, ".panel-body");
            COM.util.HTMLUtil.clearChildren(panelBody[0]);
        }
    });
})();

/**
 * Created by xiongshilin on 2017/4/5.
 */
(function() {
    AGEF.TextPropertyEditor = function(propDescriptor) {
        AGEF.TextPropertyEditor.superclass.constructor.call(this, propDescriptor);
    };
    AGEF.TextPropertyEditor.LABEL = "defaultTextEditor";
    var superClass = AGEF.PropertyEditor;
    COM.util.defineClass(AGEF.TextPropertyEditor, superClass, {
        createControl: function(propDescriptor) {
            var controlString =  '<div class="form-horizontal"><div class="form-group" style="position: relative;">' +
                '<label for="'+propDescriptor.getName()+ '" class="col-sm-2 control-label">'+propDescriptor.getTitle()+'</label>' +
                '<div class="col-sm-10">' +
                '<input type="text" class="form-control" id="'+propDescriptor.getName()+ '" value="'+propDescriptor.getValue()+ '">' +
                '</div></div></div>';
            var control = COM.util.HTMLUtil.createELement(controlString);
            this.control = control[0];
        },
        getControl: function() {
            return this.control;
        },
        setValue: function(value) {
            if(value != this.getValue()) {
                COM.util.HTMLUtil.getChildren(this.control, "input").val(value);
            }
        },
        getValue: function() {
            var value = COM.util.HTMLUtil.getChildren(this.control, "input").val();
            return value;
        },
        bindChangeHandler: function(handler) {
            COM.util.HTMLUtil.getChildren(this.control, "input").bind('input propertychange', function() {
                var request = new AGEF.ChangeValueRequest();
                request.setPropertyName(this.propDescriptor.getName());
                request.setValue(this.getValue());
                handler(request);
            }.bind(this));
        }
    });
})();
/**
 * Created by xiongshilin on 2017/4/1.
 */
(function() {
    AGEF.ActionControl = function() {
        AGEF.ActionControl.superclass.constructor.call(this);
    };
    COM.util.defineClass(AGEF.ActionControl, Object, {
        createControl: function(model, graphicalViewer) {
            var control = null;
            if(model.getConfig()) {
                control = COM.util.HTMLUtil.createELement('<button type="button" class="btn btn-default agef-action-button" style="display: inline-block;border: none;padding: 0 10px;" title="'+model.getConfig().text+'"><i style="padding-right: 5px;" class="iconfont '+model.getConfig().icon+'"></i>'+model.getConfig().text+'</button>');
            } else {
                control = COM.util.HTMLUtil.createELement('<button type="button" class="btn btn-default col-sm-6"><span class="glyphicon glyphicon-hand-up toggle"></span></button>');
            }
            this.control = control[0];
            $(this.control).click(function() {
                model.execute(graphicalViewer);
            }.bind(this));
        },
        getControl: function() {
            return this.control;
        },
        updateEnabledState : function(state){
            state ? $(this.control).removeAttr("disabled") : $(this.control).attr({"disabled": "disabled"});
        }
    });
})();
/**
 * Created by xiongshilin on 2017/4/1.
 */
(function() {
    AGEF.ActionModel = function() {
        AGEF.ActionModel.superclass.constructor.call(this);
        this.config = null;
        this.id = null;
        this.hotkeyInfo = {
                ctrlKey : false,
                shiftKey : false,
                altKey : false,
                metaKey : false,
                type : "keydown",
                key : ""
            };
    };
    AGEF.ActionModel.Label = "actionModel";
    COM.util.defineClass(AGEF.ActionModel, Object, {
        initModel: function() {

        },
        getLabel: function() {
            return AGEF.ActionModel.Label;
        },
        setConfig: function(config) {
            this.config = config;
        },
        getConfig: function() {
            return this.config;
        },
        execute : function(graphicalViewer){
            
        },
        getId : function(){
            return this.id;
        },
        getEnabledState : function(graphicalViewer){
            return true;
        },
        getHotkeyInfo : function(){
            return this.hotkeyInfo;
        },
        setHotkeyInfo : function(hotkeyInfo){
            this.hotkeyInfo = hotkeyInfo;
        }
    });
})();
/**
 * Created by zhengjiachao on 2017/6/21.
 */
(function() {
    AGEF.HotkeyHolder = function() {
        AGEF.HotkeyHolder.superclass.constructor.call(this);
        this.actions = [];
    };
    COM.util.defineClass(AGEF.HotkeyHolder, Object, {
        registerAction : function(action){
            this.actions.push(action);
        },
        rebindHotkey : function(keyInfo, actionId){
            for (var i = 0; i < this.actions.length; i++) {
                var action = this.actions[i];
                if(action.getId() === actionId){
                    action.setHotkeyInfo(keyInfo);
                }
            }
        },
        execute : function(keyInfo, graphicalViewer){
            for (var i = 0; i < this.actions.length; i++) {
                var action = this.actions[i];
                if(this.__keyMatch(action, keyInfo) && action.getEnabledState(graphicalViewer)){
                    action.execute(graphicalViewer);
                }
            }
        },
        __keyMatch : function(action, keyInfo){
            var actionKey = action.getHotkeyInfo();
            var match = true;
            if(actionKey && actionKey['key']){
                for (var attrKey in actionKey) {
                    if (actionKey.hasOwnProperty(attrKey)) {
                        var attr = actionKey[attrKey];
                        if(attr != keyInfo[attrKey]){
                            match = false;
                            break;
                        }
                    }
                }
            }else{
                match = false;
            }
            return match;
        }
    });
})();
/**
 * Created by zhengjiachao on 2017/4/26.
 */
(function() {
    AGEF.CommandActionModel = function() {
        AGEF.CommandActionModel.superclass.constructor.call(this);
    };

    COM.util.defineClass(AGEF.CommandActionModel, AGEF.ActionModel, {
        execute : function(graphicalViewer){
            AGEF.CommandActionModel.superclass.execute.call(this);
            var commands = this.getCommands(graphicalViewer);
            var domain = graphicalViewer.getEditDomain();
            var stack = domain.getCommandStack();
            for (var i = 0; i < commands.length; i++) {
                stack.execute(commands[i]);
            }
        },
        getCommands : function(graphicalViewer){
            return [];
        }
    });
})();
/**
 * Created by xiongshilin on 2017/4/1.
 */
(function(){
    AGEF.ToolbarViewer = function(container, graphicalViewer) {
        AGEF.ToolbarViewer.superclass.constructor.call(this, container);
        this.graphicalViewer = graphicalViewer;
        this.controls = new COM.draw2d.Map();
        this.actionMaps = {};
        this.createControl();
        var domain = this.graphicalViewer.getEditDomain();
        var stack = domain.getCommandStack();
        stack.addCommandStackEventListener(function(evt){
            this.updateEnabledState();
        }.bind(this));
    };
    var superClass = AGEF.AbstractAbrazosViewer;
    COM.util.defineClass(AGEF.ToolbarViewer, superClass, {
        registerControl: function(label, control) {
            if(label) {
                this.controls.put(label, control);
            } else {
                throw new Error('未指定控件的标签');
            }
        },
        getControlInstance: function(label) {
            var control = this.controls.get(label);
            if(control) {
                return new control();
            }
            return null;
        },
        createControl: function() {
            if(this.getContainer()) {
                this.control = document.createElement('div');
                this.control.style.position = 'relative';
                this.control.style.width = "100%";
                this.control.style.height = "100%";
                this.control.className += ".clearfix";
                //this.control.style.backgroundColor = "#686868";
                this.getContainer().appendChild(this.control);
            }
        },
        createToolbarEntry: function(model) {
            var control = this.getControlInstance(model.getLabel());
            control.createControl(model, this.graphicalViewer);
            this.control.appendChild(control.getControl());
            return control;
        },
        addSelectionDispatcher: function(dispatcher) {
            AGEF.ToolbarViewer.superclass.addSelectionDispatcher.call(this, dispatcher);
            this.selectionDispatcher.addListener(AGEF.AbrazosGraphicalViewerImpl.SELECTION_GRAPHICAL, {update: function(arg) {
                this.updateEnabledState();
            }.bind(this)});
        },
        updateEnabledState : function(){
            for(var i = 0; i < this.contents.length; i++){
                var model = this.contents[i];
                var control = this.actionMaps[model.getId()];
                control.updateEnabledState(model.getEnabledState(this.graphicalViewer));
            }
        },
        setContents: function(contents) {
            this.contents = contents;
            for(var i in contents) {
                var control = this.createToolbarEntry(contents[i]);
                if(this.actionMaps[contents[i].getId()]){
                    console.error("duplicated action model id : " + contents[i].getId());
                }else{
                    this.actionMaps[contents[i].getId()] = control;
                }
            }
            this.updateEnabledState();
        }
    });
})();
/**
 * Created by xiongshilin on 2017/4/11.
 */
(function(){
    AGEF.AbstractTree = function() {
        AGEF.AbstractTree.superclass.constructor.call(this);
        this.control = null;
        this.internalTree = null;
        this.listener = [];
        this.modelToNodeMap = new COM.draw2d.Map();
        this.createControl();
    };

    COM.util.defineClass(AGEF.AbstractTree, Object, {
        createControl: Function.needOverride,
        initTree: Function.needOverride,
        getControl: function () {
            return this.control;
        },
        addListener: function(listener) {
            this.listener.push(listener);
        },
        removeListener: function(listener) {
            COM.util.removeItem(this.listener, listener);
        },
        fireOutlineChange: function(evt) {
            for(var index in this.listener) {
                this.listener[index].outlineUpdate(evt);
            }
        },
        getInternalTree: function() {
            return this.internalTree;
        },
        addNode: Function.needOverride,
        removeNode: Function.needOverride,
        createTreeNode: Function.needOverride,
        setSelection: Function.needOverride
    });
})();
/**
 * Created by xiongshilin on 2017/4/11.
 */
(function(){
    AGEF.AbstractTreeNode = function(parent, id) {
        AGEF.AbstractTreeNode.superclass.constructor.call(this);
        this.parent = parent;
        this.id = id;
        this.children = [];
        this.control = null;
    };

    COM.util.defineClass(AGEF.AbstractTreeNode, Object, {
        createControl:Function.emptyFunction,
        addChild: function(child) {
            this.children.push(child);
        },
        removeChild: function(child) {
            COM.util.removeItem(this.children, child);
        },
        getControl: function() {
            return this.control;
        },
        getParent: function() {
            return this.parent;
        },
        setParent: function(parent) {
          this.parent = parent;
        },
        getInternalTree: function() {
            return this.parent.getInternalTree();
        },
        getID: function() {
            return this.id;
        },
        getTree: function() {
            if(this.parent instanceof AGEF.AbstractTree) {
                return this.parent;
            } else {
                return this.parent.getTree();
            }
        },
        hasChildren: function() {
            return this.children.length > 0;
        },
        dispose: function() {
            this.parent = null;
            this.id = null;
            this.control = null;
        },
        propertyChange: Function.emptyFunction,
        isSelected: Function.needOverride,
        setText: Function.needOverride,
        toInternalTreeNode: Function.emptyFunction
    });
})();
/**
 * Created by xiongshilin on 2017/4/11.
 */
(function(){
    AGEF.OutlineTreeNode = function(parent, id) {
        AGEF.OutlineTreeNode.superclass.constructor.call(this, parent, id);
        this.parent = parent;
        this.id = id;
        this.listenerProxies = [];
        this.model = null;
    };
    var superclass = AGEF.AbstractTreeNode;
    COM.util.defineClass(AGEF.OutlineTreeNode, superclass, {
        createControl: function(model) {
            if(model instanceof AGEF.BaseModel) {
                this.model = model;
                var listenerProxy = new COM.draw2d.PropertyChangeListenerProxy("children", this);
                model.addPropertyChangeListener(listenerProxy);
                this.listenerProxies.push(listenerProxy);
                listenerProxy = new COM.draw2d.PropertyChangeListenerProxy("name", this);
                model.addPropertyChangeListener(listenerProxy);
                this.listenerProxies.push(listenerProxy);
                this.getTree().addNode(this.toInternalTreeNode());
                var childrenModel = model.getPropertyValue("children");
                if(childrenModel && childrenModel.length > 0) {
                    for(var index in childrenModel) {
                        this.addChild(childrenModel[index]);
                    }
                }
            }
        },
        dispose: function() {
            this.getTree().removeNode(this.id);
            if(!this.model) {
                return;
            }
            for(var index in this.listenerProxies) {
                this.model.removePropertyChangeListener(this.listenerProxies[index]);
            }
            var childrenModel = this.model.getPropertyValue("children");
            if(childrenModel && childrenModel.length > 0) {
                for(var index in childrenModel) {
                    this.removeChild(childrenModel[index]);
                }
            }
            this.model = null;
            this.listenerProxies = [];
            AGEF.OutlineTreeNode.superclass.dispose.call(this);
        },
        hasChildren: function() {
            var childrenModel = this.model.getPropertyValue("children");
            if(childrenModel/* && childrenModel.length > 0*/) {
                return true;
            }
        },
        addChild: function(model) {
            var node = this.getTree().modelToNodeMap.get(model);
            if(node) {
                node.setParent(this);
                this.getInternalTree().jstree(true).move_node(node.getID(), this.id, "last");
            } else {
                node = new AGEF.OutlineTreeNode(this, COM.util.ObjUtil.guid());
                node.createControl(model);
                this.getTree().modelToNodeMap.put(model, node);
            }
            return node;
        },
        removeChild: function(model) {
            var deleteNode = this.getTree().modelToNodeMap.get(model);
            if(deleteNode) {
                this.getTree().modelToNodeMap.remove(model);
                deleteNode.dispose();
            }
        },
        propertyChange: function(evt) {
            if(AGEF.PropertyChangeEvent.UPDATE_EVENT == evt.getType()) {
                if("name" == evt.getPropertyName()){
                    this.getInternalTree().jstree(true).rename_node(this.id, evt.getNewValue());
                } else if("children" == evt.getPropertyName()) {
                    var newValue = evt.getNewValue(), oldValue = evt.getOldValue();
                    if(newValue.length > oldValue.length) {
                        //新增
                        for(var i in newValue) {

                            if(!COM.util.Array.contains(oldValue, newValue[i])) {
                                var newNode = this.addChild(newValue[i]);
                                this.getInternalTree().jstree(true).deselect_all(true);
                                this.getInternalTree().jstree(true).select_node([newNode.getID()]);
                            }
                        }
                    } else if(newValue.length < oldValue.length) {
                        //删除
                        for(var j in oldValue) {
                            if(!COM.util.Array.contains(newValue, oldValue[j])) {
                                this.removeChild(oldValue[j]);
                            }
                        }
                    }
                }
            }
        },
        /*intersect: function(newValues, oldValues){
            var intersection = [];
            for(var i in newValues) {
                if(oldValues.contain(newValues[i])) {
                    intersection.push(newValues[i]);
                }
            }
            return intersection;
        },*/
        isSelected: function() {
            return this.getInternalTree().jstree(true).is_selected(this.id);
        },
        setText: function(text) {
            this.getInternalTree().jstree(true).is_selected(this.id);
        },
        toInternalTreeNode: function() {
            var jsonObject = {};
            jsonObject.model = this.model;
            jsonObject.id = this.id;
            jsonObject.parent = this.parent.getID ? this.parent.getID() : "#";
            jsonObject.text = this.model.getPropertyValue("name") ? this.model.getPropertyValue("name") : "nameless";
            var modelType = jsonObject.model._getModelType(),
                modelIcon = jsonObject.model.getConfig().icon;
            if(!this.hasChildren()) {
                if(modelIcon){
                    jsonObject.icon = "iconfont "+modelIcon;
                }else{
                    if(modelType == "ADF.model.NumberModel" || modelType == "BCP.bill.model.NumberModel"){
                        jsonObject.icon = "iconfont icon-number";
                    }else if(modelType == "ADF.model.ButtonModel" || modelType == "BCP.bill.model.ButtonModel"){
                        jsonObject.icon = "iconfont icon-btn";
                    }else if(modelType == "ADF.model.LabelModel" || modelType == "BCP.bill.model.LabelModel"){
                        jsonObject.icon = "iconfont icon-label";
                    }else if(modelType == "ADF.model.InputModel" || modelType == "BCP.bill.model.InputModel"){
                        jsonObject.icon = "iconfont icon-input";
                    }else if(modelType == "ADF.model.ImageModel" || modelType == "BCP.bill.model.ImageModel"){
                        jsonObject.icon = "iconfont icon-pic";
                    }else if(modelType == "ADF.model.TextAreaModel" || modelType == "BCP.bill.model.TextAreaModel"){
                        jsonObject.icon = "iconfont icon-textarea";
                    }else if(modelType == "ADF.model.DatetimeModel" || modelType == "BCP.bill.model.DatetimeModel"){
                        jsonObject.icon = "iconfont icon-Datetime";
                    }else if(modelType == "ADF.model.ButtonForGroupModel" || modelType == "BCP.bill.model.ButtonForGroupModel"){
                        jsonObject.icon = "iconfont icon-btnfg";
                    }else if(modelType == "BCP.bill.model.SubtableModel"){
                        jsonObject.icon = "iconfont icon-biaoti1";
                    }else if(modelType == "BCP.bill.model.ListbasedataModel"){
                        jsonObject.icon = "iconfont icon-radio";
                    }
                }
            }else{
                if(modelIcon){
                    jsonObject.icon = "iconfont "+modelIcon;
                }else{
                    if(modelType == "ADF.model.ButtonGroupModel"){
                        jsonObject.icon = "iconfont icon-buttonG";
                    }else if(modelType == "ADF.model.XYCompositeModel"){
                        jsonObject.icon = "iconfont icon-compoaite";
                    }else if(modelType == "ADF.model.BootstrapContainerModel"){
                        jsonObject.icon = "iconfont icon-chuangjiangongzuokongjian1";
                    }else if(modelType == "ADF.model.BootstrapRowModel"){
                        jsonObject.icon = "iconfont icon-hengdian";
                    }else if(modelType == "ADF.model.BootstrapColumnModel"){
                        jsonObject.icon = "iconfont icon-shudian";
                    }else {
                        jsonObject.icon = "iconfont icon-weizhankaiwenjianjia";
                    }
                }
            }
            return jsonObject;
        }
    });
})();


/**
 * Created by xiongshilin on 2017/4/11.
 */
(function(){
    AGEF.OutlineTree = function() {
        AGEF.OutlineTree.superclass.constructor.call(this);
        this.children = [];
    };
    var superclass = AGEF.AbstractTree;
    AGEF.OutlineTree.LABEL = "outlineTree";
    COM.util.defineClass(AGEF.OutlineTree, superclass, {
        createControl: function () {
            this.control = document.createElement('div');
            this.control.style.position = 'relative';
            this.control.id = "outlineTree";
        },
        initTree: function (data) {
            this.internalTree = COM.util.HTMLUtil.createJSTree(this.control, {"core":{"check_callback":true}});
            this.internalTree.jstree(true).hide_dots();
            this.internalTree.on("select_node.jstree", function(e, data){
                var refModels = [];
                for(var i = 0, j = data.selected.length; i < j; i++) {
                    refModels.push(data.node.original.model);
                }
                this.fireOutlineChange({"type": "selection", "data": refModels})
            }.bind(this));
            this.initInternalTree(data);
        },
        addNode: function(jsonObject) {
            this.internalTree.jstree(true).create_node(jsonObject["parent"], jsonObject);
        },
        removeNode: function(id){
            this.internalTree.jstree(true).delete_node(id);
        },
        initInternalTree: function (modelData) {
            var rootNode = new AGEF.OutlineTreeNode(this, COM.util.ObjUtil.guid());
            rootNode.createControl(modelData);
            /*var jsonObject = {};
            if(parentID == null) {
                jsonObject["model"] = modelData, jsonObject["id"] = "contentModel", jsonObject["parent"] = "#", jsonObject["text"] = "Content";
            } else {
                jsonObject = {"model":modelData, "id":COM.util.ObjUtil.guid(), "parent":parentID, "text":modelData.getText?modelData.getText():null, "icon":"glyphicon glyphicon-leaf"};
            }
            this.modelToNodeMap.put(modelData, jsonObject["id"]);
            this.addNode(jsonObject);
            if(modelData.getChildren) {
                var children = modelData.getChildren();
                for(var index in children) {
                    this.createTreeNode(jsonObject["id"], children[index]);
                }
            }*/
        },
        setSelection: function(selecton) {
            var nodeIds = [];
            for(var index in selecton) {
                var nodeId = this.modelToNodeMap.get(selecton[index].getModel());
                if(!this.isSelected(nodeId)) {
                    nodeIds.push(nodeId);
                }
            }
            if(nodeIds.length > 0) {
                this.internalTree.jstree(true).deselect_all(true);
                this.internalTree.jstree(true).select_node(nodeIds);
            }
        },
        isSelected: function(id) {
            return this.internalTree.jstree(true).is_selected(id);
        }
    });
})();
/**
 * Created by xiongshilin on 2017/4/1.
 */
(function(){
    AGEF.OutlineViewer = function(container) {
        AGEF.OutlineViewer.superclass.constructor.call(this, container);
        this.createControl();
        this.outlineTree = null;
    };
    AGEF.OutlineViewer.OUTLINE_CHANGE = "outlineChange";
    var superClass = AGEF.AbstractAbrazosViewer;
    COM.util.defineClass(AGEF.OutlineViewer, superClass, {
        createControl: function() {
            this.control = document.createElement('div');
            this.control.style.position = 'relative';
            this.control.style.width = "100%";
            this.control.style.height = "-webkit-calc(100% - 33px)";
            this.control.style.height = "-moz-calc(100% - 33px)";
            this.control.style.height = "calc(100% - 33px)";
            this.control.style.paddingBottom = "10px";
            this.control.style.overflow = "auto";
            this.control.className = "outlineViewer";
            this.getContainer().appendChild(this.control);
        },
        setOutlineTree: function(outlineTree) {
            this.outlineTree = outlineTree;
        },
        getOutlineTree: function() {
            if(this.outlineTree == null) {
                this.outlineTree = new AGEF.OutlineTree();
            }
            return this.outlineTree;
        },
        addSelectionDispatcher: function(dispatcher) {
            AGEF.OutlineViewer.superclass.addSelectionDispatcher.call(this, dispatcher);
            this.selectionDispatcher.addListener(AGEF.AbrazosGraphicalViewerImpl.SELECTION_GRAPHICAL, {update: function(arg) {
                if(arg && arg.selection) {
                    this.outlineTree.setSelection(arg.selection);
                }
            }.bind(this)});
        },
        setContents: function(contents) {
            var outlineTree = this.getOutlineTree();
            outlineTree.addListener(this);
            this.control.appendChild(outlineTree.getControl());
            outlineTree.initTree(contents);
        },
        outlineUpdate: function(evt) {
            this.selectionDispatcher.notifyChange(AGEF.OutlineViewer.OUTLINE_CHANGE, evt);
        }
    });
})();
/**
 * Created by xiongshilin on 2017/3/28.
 */
(function(){
    AGEF.EditorPart = function() {};
    AGEF.EditorPart.prototype.initConfigure = Function.needOverride;
    AGEF.EditorPart.prototype.setEditorPartConfigure = Function.needOverride;
    AGEF.EditorPart.prototype.getEditorPartConfigure = Function.needOverride;
    AGEF.EditorPart.prototype.configureAbrazosViewers = Function.needOverride;
    AGEF.EditorPart.prototype.initAbrazosViewers = Function.needOverride;
    AGEF.EditorPart.prototype.configureAbrazosGraphicalViewer = Function.needOverride;
    AGEF.EditorPart.prototype.initAbrazosGraphicalViewer = Function.needOverride;
    AGEF.EditorPart.prototype.configureAbrazosPaletteViewer = Function.needOverride;
    AGEF.EditorPart.prototype.initAbrazosPaletteViewer = Function.needOverride;
    AGEF.EditorPart.prototype.configureAbrazosToolBarViewer = Function.needOverride;
    AGEF.EditorPart.prototype.initAbrazosToolBarViewer = Function.needOverride;
    AGEF.EditorPart.prototype.configureAbrazosOutlineViewer = Function.needOverride;
    AGEF.EditorPart.prototype.initAbrazosOutlineViewer = Function.needOverride;
    AGEF.EditorPart.prototype.configureAbrazosPropertyViewer = Function.needOverride;
    AGEF.EditorPart.prototype.initAbrazosPropertyViewer = Function.needOverride;
    AGEF.EditorPart.prototype.selectionService = Function.needOverride;
    AGEF.EditorPart.prototype.addViewer = Function.needOverride;
    AGEF.EditorPart.prototype.open = Function.needOverride;
    AGEF.EditorPart.prototype.getContents = Function.needOverride;
})();
/**
 * Created by xiongshilin on 2017/4/10.
 */
(function(){
    AGEF.SelectionDispatcher = function(holder) {
        AGEF.SelectionDispatcher.superclass.constructor.call(this);
        this.holder = holder;
        this.changeAndListenerMap = new AGEF.Map();
    };
    COM.util.defineClass(AGEF.SelectionDispatcher, Object, {
        notifyChange: function(token, evt) {
            if(this.changeAndListenerMap.getValue(token)) {
                var listeners = this.changeAndListenerMap.getValue(token);
                for(var index in listeners) {
                    listeners[index].update(evt);
                }
            } else {
                this.changeAndListenerMap.put(token, []);
            }
        },
        addListener: function(token, listener) {
            if(this.changeAndListenerMap.getValue(token)) {
                var listeners = this.changeAndListenerMap.getValue(token);
                listeners.push(listener);
            } else {
                this.changeAndListenerMap.put(token, [listener]);
            }
        },
        removeListener: function(token, listener) {
            if(this.changeAndListenerMap.getValue(token)) {
                COM.util.removeItem(this.changeAndListenerMap.getValue(token), listener);
            }
        }
    });
})();
/**
 * Created by xiongshilin on 2017/4/1.
 */
(function() {
    AGEF.EditorPartConfigure = function() {
        this.showGraphicalViewer = true;
        this.showPaletteViewer = false;
        this.showOutlineViewer = false;
        this.showToolbarViewer = false;
        this.showPropertyViewer = false;
    };

    COM.util.defineClass(AGEF.EditorPartConfigure, Object, {
        isShowGraphicalViewer: function() {
            return this.showGraphicalViewer;
        },
        isShowPaletteViewer: function() {
            return this.showPaletteViewer;
        },
        isShowOutlineViewer: function() {
            return this.showOutlineViewer;
        },
        isShowToolbarViewer: function() {
            return this.showToolbarViewer;
        },
        isShowPropertyViewer: function() {
            return this.showPropertyViewer;
        },
        setShowGraphicalViewer: function(flag) {
            this.showGraphicalViewer = flag;
        },
        setShowPaletteViewer: function(flag) {
            this.showPaletteViewer = flag;
        },
        setShowOutlineViewer: function(flag) {
            this.showOutlineViewer = flag;
        },
        setShowToolbarViewer: function(flag) {
            this.showToolbarViewer = flag;
        },
        setShowPropertyViewer: function(flag) {
            this.showPropertyViewer = flag;
        }
    });
})();
/**
 * Created by xiongshilin on 2017/4/1.
 */
(function() {
    AGEF.AbstractEditorPart = function(inputs) {
        AGEF.AbstractEditorPart.superclass.constructor.call(this);
        this.configure = new AGEF.EditorPartConfigure();
        this.selectionDispatcher = new AGEF.SelectionDispatcher(this);
        this.inputs = inputs;
        this.viewers = [];
        this.container = null;
        this.contentModel = null;
    };
    var superClass = AGEF.EditorPart;
    COM.util.defineClass(AGEF.AbstractEditorPart, superClass, {
        initConfigure: function(){
            this.configure.setShowPaletteViewer(true);
            this.configure.setShowPropertyViewer(true);
            this.configure.setShowOutlineViewer(true);
            this.configure.setShowToolbarViewer(true);
        },
        configureAbrazosViewers: function() {
            if(this.configure.isShowGraphicalViewer()) {
                this.configureAbrazosGraphicalViewer();
            }
            if(this.configure.isShowPaletteViewer()) {
                this.configureAbrazosPaletteViewer();
            }
            if(this.configure.isShowOutlineViewer()) {
                this.configureAbrazosOutlineViewer();
            }
            if(this.configure.isShowToolbarViewer()) {
                this.configureAbrazosToolBarViewer();
            }
            if(this.configure.isShowPropertyViewer()) {
                this.configureAbrazosPropertyViewer();
            }
        },
        initAbrazosViewers: function() {
            if(this.configure.isShowGraphicalViewer()) {
                this.initAbrazosGraphicalViewer();
            }
            if(this.configure.isShowPaletteViewer()) {
                this.initAbrazosPaletteViewer();
            }
            if(this.configure.isShowOutlineViewer()) {
                this.initAbrazosOutlineViewer();
            }
            if(this.configure.isShowToolbarViewer()) {
                this.initAbrazosToolBarViewer();
            }
            if(this.configure.isShowPropertyViewer()) {
                this.initAbrazosPropertyViewer();
            }
        },
        setEditorPartConfigure: function(configure) {
            this.configure = configure;
        },
        getEditorPartConfigure: function() {
            return this.configure;
        },
        selectionService: function(message) {
            for(var i = 0,j=this.viewers.length; i<j; i++) {
                if(this.viewers[i] == message.source)
                    continue;
                this.viewers[i].selectionChanged(message);
            }
        },
        getContainer: function() {
            return this.container;
        },
        getInputs: function() {
            return this.inputs;
        },
        addViewer: function(viewer) {
            viewer.addSelectionDispatcher(this.selectionDispatcher);
            this.viewers.push(viewer);
        },
        getViewers: function() {
            return this.viewers;
        },
        open: function() {
           if(this.inputs) {
               this.initConfigure();
               this.configureAbrazosViewers();
               this.initAbrazosViewers();
           }
        },
        getContents: function() {
            var data = {"htmlData":"","contentData":""};
            for(var index in this.viewers) {
                if(this.viewers[index] instanceof COM.gef.EditPartViewer) {
                    var rootEditPart = this.viewers[index].getRootEditPart();
                    var rootControl = rootEditPart.getFigure().getWidget().getDomElement();
                    data["htmlData"] = COM.util.HTMLUtil.domToString(rootControl, false);
                    break;
                }
            }
            if(this.inputs && this.inputs.contents && null != this.contentModel) {
                data["contentData"] = this.contentModel.serialize();
            }
            return COM.util.ObjUtil.stringify(data);
        }
    });
})();
/**
 * Created by xiongshilin on 2017/3/28.
 */
(function(){
    AGEF.DefaultEditor = function(inputs) {
        AGEF.DefaultEditor.superclass.constructor.call(this, inputs);
    };
    var superClass = AGEF.AbstractEditorPart;
    COM.util.defineClass(AGEF.DefaultEditor, superClass, {
        initConfigure: function () {
            AGEF.DefaultEditor.superclass.initConfigure.call(this);
            if(!this.inputs) {
                throw new Error('未指定输入数据');
            }
            if(!this.inputs.editorContainer) {
                throw new Error('没有提供编辑器容器');
            }
            this.container = this.inputs.editorContainer;
        },
        configureAbrazosGraphicalViewer: function() {
            if(!this.inputs.graphicalContainer) {
                throw new Error('没有指定图形视图的容器');
            }
            if(!this.inputs.editPartFactory) {
                throw new Error('没有指定创建EditPart的工厂');
            }
            if(!this.inputs.widgetFactory) {
                throw new Error('没有指定创建Widget的工厂');
            }
            var viewers = this.createGraphicalViewers(this.inputs);
            for(var i in viewers) {
                this.addViewer(viewers[i]);
            }
        },
        createGraphicalViewers: function(inputs) {
            var graphicalViewers = [];
            var shell = document.createElement('div'), width = 1800, height = 1200, domain = null, graphicalViewer= null;
            shell.style.position = 'absolute';
            shell.style.width = width+"px";
            shell.style.height = height+"px";
            inputs.graphicalContainer.appendChild(shell);
            domain = new AGEF.AbrazosEditDomain(shell);
            graphicalViewer = this.doCreateGraphicalViewer();
            graphicalViewer.setSize(width-2, height-2);
            graphicalViewer.setEditPartFactory(inputs.editPartFactory);
            graphicalViewer.setWidgetFactory(inputs.widgetFactory);
            domain.addViewer(graphicalViewer);
            graphicalViewers.push(graphicalViewer);
            return graphicalViewers;
        },
        doCreateGraphicalViewer : function(){
            return new AGEF.AbrazosGraphicalViewerImpl();
        },
        configureAbrazosPaletteViewer: function() {
            if(!this.inputs.paletteContainer) {
                throw new Error('没有指定Palette视图的容器');
            }
            var viewers = this.createPaletteViewers(this.inputs);
            for(var i in viewers) {
                this.addViewer(viewers[i]);
            }
        },
        createPaletteViewers: function(inputs) {
            var paletteViewers = [];
            var paletteViewer = this.createPaletteViewerInstence(inputs.paletteContainer);
            paletteViewer.registerControl(AGEF.PaletteGroup.LABEL, AGEF.PaletteGroup);
            paletteViewer.registerControl(AGEF.ToolEntry.LABEL, AGEF.ToolEntry);

            paletteViewer.registerTool(AGEF.AbrazosSelectionTool.LABEL, AGEF.AbrazosSelectionTool);
            paletteViewer.registerTool(AGEF.AbrazosCreationTool.LABEL, AGEF.AbrazosCreationTool);
            paletteViewer.registerTool(AGEF.AbrazosMarqueeSelectionTool.LABEL, AGEF.AbrazosMarqueeSelectionTool);

            paletteViewers.push(paletteViewer);
            return paletteViewers;
        },
        createPaletteViewerInstence : function(container){
            return new AGEF.PaletteViewer(container);
        },
        configureAbrazosToolBarViewer: function() {
            if(!this.inputs.toolbarContainer) {
                throw new Error('没有指定Toolbar视图的容器');
            }
            var graphicalViewer = null;
            for(var i = 0; i < this.viewers.length; i++){
                if(this.viewers[i] instanceof AGEF.AbrazosGraphicalViewerImpl){
                    graphicalViewer = this.viewers[i];
                    break;
                }
            }
            if(!graphicalViewer) {
                throw new Error('没有初始化GraphicalViewer');
            }
            var viewers = this.createToolbarViewers(this.inputs, graphicalViewer);
            for(var i in viewers) {
                this.addViewer(viewers[i]);
            }
        },
        createToolbarViewers: function(inputs, graphicalViewer) {
            var toolbarViewers = [];
            var toolbarViewer = new AGEF.ToolbarViewer(inputs.toolbarContainer, graphicalViewer);
            toolbarViewer.registerControl(AGEF.ActionModel.Label, AGEF.ActionControl);
            toolbarViewers.push(toolbarViewer);
            return toolbarViewers;
        },
        configureAbrazosPropertyViewer: function() {
            if(!this.inputs.propertyContainer) {
                throw new Error('没有指定属性视图的容器');
            }
            var viewers = this.createPropertyViewers(this.inputs);
            for(var i in viewers) {
                this.configurePropertyControl(viewers[i]);
                this.addViewer(viewers[i]);
            }
        },
        createPropertyViewers: function(inputs) {
            var propertyViewers = [];
            var propertyViewer = new AGEF.PropertyViewer(inputs.propertyContainer);
            propertyViewers.push(propertyViewer);
            return propertyViewers;
        },
        configurePropertyControl: function(propertyViewer) {
            propertyViewer.registerControl(AGEF.PropertyGroup.LABEL, AGEF.PropertyGroup);
            propertyViewer.registerControl(AGEF.TextPropertyEditor.LABEL, AGEF.TextPropertyEditor);
        },
        configureAbrazosOutlineViewer: function() {
            if(!this.inputs.outlineContainer) {
                throw new Error('没有指定大纲视图的容器');
            }
            var viewers = this.createOutlineViewer(this.inputs);
            for(var i in viewers) {
                this.addViewer(viewers[i]);
            }
        },
        createOutlineViewer: function(inputs) {
            var outlineViewers = [];
            var outlineViewer = new AGEF.OutlineViewer(inputs.outlineContainer);
            outlineViewers.push(outlineViewer);
            return outlineViewers;
        },
        initAbrazosGraphicalViewer: function() {
            if(this.inputs.contents) {
                var viewers = this.getViewers();
                for(var i in viewers) {
                    if(viewers[i] instanceof COM.gef.EditPartViewer) {
                        if(typeof this.inputs.contents === "string") {
                            var jsonContent = COM.util.ObjUtil.parseJSON(this.inputs.contents);
                            if(jsonContent["contentData"]) {
                                jsonContent = COM.util.ObjUtil.parseJSON(jsonContent["contentData"])
                            }
                            var modelType = jsonContent["modelType"], modelConstructor = eval("("+modelType+")");
                            var contentModel = new modelConstructor();
                            contentModel.deserialize(JSON.stringify(jsonContent));
                            this.contentModel = contentModel;
                        } else {
                            this.contentModel = this.inputs.contents;
                        }
                        viewers[i].setContents(this.contentModel)
                    }
                }
            }
        },
        initAbrazosPaletteViewer: function() {
            if(this.inputs.paletteContents) {
                var viewers = this.getViewers();
                for(var i in viewers) {
                    if(viewers[i] instanceof AGEF.PaletteViewer) {
                        viewers[i].setContents(this.inputs.paletteContents);
                    }
                }
            }
        },
        initAbrazosToolBarViewer: function() {
            if(this.inputs.toolbarContents) {
                var viewers = this.getViewers();
                for(var i in viewers) {
                    if(viewers[i] instanceof AGEF.ToolbarViewer) {
                        viewers[i].setContents(this.inputs.toolbarContents);
                    }
                }
            }
        },
        initAbrazosPropertyViewer: function() {
            if(this.inputs.propertyContents) {
                var viewers = this.getViewers();
                for(var i in viewers) {
                    if(viewers[i] instanceof AGEF.PropertyViewer) {
                        viewers[i].setContents(this.inputs.propertyContents);
                    }
                }
            }
        },
        initAbrazosOutlineViewer: function() {
            if(this.contentModel) {
                var viewers = this.getViewers();
                for(var i in viewers) {
                    if(viewers[i] instanceof AGEF.OutlineViewer) {
                        viewers[i].setContents(this.contentModel);
                    }
                }
            }
        }
    });
})();
